1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-29 16:50:10 +02:00

DownloadFileThread now removes all illegal chars from filenames before trying to write the file to disk

This commit is contained in:
cyian-1756
2018-10-28 08:07:13 -04:00
parent debba69c7f
commit 5b78ba0266

View File

@@ -62,12 +62,19 @@ class DownloadFileThread extends Thread {
this.cookies = cookies; this.cookies = cookies;
} }
public File sanitizeSaveAs(File fileToSan) {
String fileName = fileToSan.getName().replaceAll("[\\\\/:*?\"<>|]", "_");
return new File(saveAs.getParentFile().getAbsolutePath() + File.separator + fileName);
}
/** /**
* Attempts to download the file. Retries as needed. * Attempts to download the file. Retries as needed.
* Notifies observers upon completion/error/warn. * Notifies observers upon completion/error/warn.
*/ */
public void run() { public void run() {
// First thing we make sure the file name doesn't have any illegal chars in it
saveAs = sanitizeSaveAs(saveAs);
long fileSize = 0; long fileSize = 0;
int bytesTotal = 0; int bytesTotal = 0;
int bytesDownloaded = 0; int bytesDownloaded = 0;