Check storage before download image
This commit is contained in:
1 parent
9b60cdc612
commit
389119c468
2 files changed
+17
-1
No files matched your search
@@ -76,6 +76,11 @@ public final class SpiderDen {
|
||||
if (dir != null) {
|
||||
// Read from DB
|
||||
String dirname = EhDB.getDownloadDirname(galleryInfo.gid);
|
||||
if (null != dirname) {
|
||||
// Some dirname may be invalid in some version
|
||||
dirname = FileUtils.sanitizeFilename(dirname);
|
||||
EhDB.putDownloadDirname(galleryInfo.gid, dirname);
|
||||
}
|
||||
|
||||
// Find it
|
||||
if (null == dirname) {
|
||||
@@ -128,6 +133,17 @@ public final class SpiderDen {
|
||||
return mDownloadDir != null && mDownloadDir.ensureDir();
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
switch (mMode) {
|
||||
case SpiderQueen.MODE_READ:
|
||||
return sCache != null;
|
||||
case SpiderQueen.MODE_DOWNLOAD:
|
||||
return mDownloadDir != null && mDownloadDir.isDirectory();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UniFile getDownloadDir() {
|
||||
return mDownloadDir != null && mDownloadDir.isDirectory() ? mDownloadDir : null;
|
||||
|
||||
@@ -1238,7 +1238,7 @@ public class SpiderQueen implements Runnable {
|
||||
Log.i(TAG, Thread.currentThread().getName() + ": start");
|
||||
}
|
||||
|
||||
while (!Thread.currentThread().isInterrupted() && runInternal());
|
||||
while (mSpiderDen.isReady() && !Thread.currentThread().isInterrupted() && runInternal());
|
||||
|
||||
boolean finish;
|
||||
// Clear in spider worker array
|
||||
|
||||
Reference in new issue
Block a user