Skip to content

Commit

Permalink
deleteLocalcache (#856)
Browse files Browse the repository at this point in the history
* Update the translation

* delete cache files

* judge isDir

* judge list exists show

* Modify the cache judgment logic
  • Loading branch information
maxiaoping committed May 23, 2020
1 parent 5a5a708 commit 6b5bc63
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Expand Up @@ -7,8 +7,8 @@ android {
applicationId 'com.seafile.seadroid2'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 101
versionName "2.2.26"
versionCode 102
versionName "2.2.27"
multiDexEnabled true
resValue "string", "authorities", applicationId + '.cameraupload.provider'
resValue "string", "account_type", "com.seafile.seadroid2.account.api2"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/seafile/seadroid2/data/SeafDirent.java
Expand Up @@ -48,6 +48,10 @@ public boolean isDir() {
return (type == DirentType.DIR);
}

public long getFileSize() {
return size;
}

@Override
public String getTitle() {
return name;
Expand Down
Expand Up @@ -362,7 +362,7 @@ private void setFileView(SeafDirent dirent, Viewholder viewHolder, int position)
}
boolean cacheExists = false;

if (file.exists()) {
if (file.exists() && file.length() == dirent.getFileSize()) {
SeafCachedFile cf = dataManager.getCachedFile(repoName, repoID, filePath);
String subtitle = null;
subtitle = dirent.getSubtitle();
Expand Down
Expand Up @@ -46,6 +46,7 @@
import com.seafile.seadroid2.util.ConcurrentAsyncTask;
import com.seafile.seadroid2.util.Utils;

import java.io.File;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -948,7 +949,23 @@ protected List<SeafDirent> doInBackground(String... params) {
myRepoID = params[1];
myPath = params[2];
try {
return dataManager.getDirentsFromServer(myRepoID, myPath);
List<SeafDirent> dirents = dataManager.getDirentsFromServer(myRepoID, myPath);
for (SeafDirent sd : dirents) {
if (!sd.isDir()) {
String repoName = getNavContext().getRepoName();
String repoID = getNavContext().getRepoID();
String path = Utils.pathJoin(getNavContext().getDirPath(), sd.name);
File localfile = dataManager.getLocalRepoFile(repoName, repoID, path);
long localfileSize = localfile.length();
if (localfileSize != sd.getFileSize()) {
SeafCachedFile scf = dataManager.getCachedFile(repoName, repoID, path);
if (scf != null) {
dataManager.removeCachedFile(scf);
}
}
}
}
return dirents;
} catch (SeafException e) {
err = e;
return null;
Expand Down

0 comments on commit 6b5bc63

Please sign in to comment.