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:
commit
92d21a121c
@ -72,9 +72,26 @@ public abstract class AbstractRipper
|
|||||||
FileWriter fw = null;
|
FileWriter fw = null;
|
||||||
try {
|
try {
|
||||||
File file = new File(URLHistoryFile);
|
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 doesnt exists, then create it
|
||||||
if (!file.exists()) {
|
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);
|
fw = new FileWriter(file.getAbsoluteFile(), true);
|
||||||
bw = new BufferedWriter(fw);
|
bw = new BufferedWriter(fw);
|
||||||
|
Loading…
Reference in New Issue
Block a user