1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-18 19:51:35 +02:00

Merge pull request #617 from cyian-1756/permissionsChecks

Now checks that URLHistory exists and that we can write to it before …
This commit is contained in:
cyian-1756
2018-05-25 15:55:51 -04:00
committed by GitHub

View File

@@ -72,9 +72,26 @@ public abstract class AbstractRipper
FileWriter fw = null;
try {
File file = new File(URLHistoryFile);
if (!new File(Utils.getConfigDir()).exists()) {
logger.error("Config dir doesn't exist");
logger.info("Making config dir");
boolean couldMakeDir = new File(Utils.getConfigDir()).mkdirs();
if (!couldMakeDir) {
logger.error("Couldn't make config dir");
return;
}
}
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
boolean couldMakeDir = file.createNewFile();
if (!couldMakeDir) {
logger.error("Couldn't url history file");
return;
}
}
if (!file.canWrite()) {
logger.error("Can't write to url history file: " + URLHistoryFile);
return;
}
fw = new FileWriter(file.getAbsoluteFile(), true);
bw = new BufferedWriter(fw);