Fix: File can not be shown after several actions

This commit is contained in:
masensio 2014-05-16 14:25:18 +02:00
parent 6f84897197
commit 9a9d4e0677

View file

@ -467,8 +467,7 @@ public class FileDataStorageManager {
success = removeFolderInDb(folder); success = removeFolderInDb(folder);
} }
if (removeLocalContent && success) { if (removeLocalContent && success) {
File localFolder = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, folder)); success = removeLocalFolder(folder);
success = removeLocalFolder(localFolder);
} }
} }
return success; return success;
@ -491,20 +490,28 @@ public class FileDataStorageManager {
return deleted > 0; return deleted > 0;
} }
private boolean removeLocalFolder(File folder) { private boolean removeLocalFolder(OCFile folder) {
boolean success = true; boolean success = true;
if (folder.exists()) { File localFolder = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, folder));
File[] files = folder.listFiles(); if (localFolder.exists()) {
Vector<OCFile> files = getFolderContent(folder.getFileId());
if (files != null) { if (files != null) {
for (File file : files) { for (OCFile file : files) {
if (file.isDirectory()) { if (file.isFolder()) {
success &= removeLocalFolder(file); success &= removeLocalFolder(file);
} else { } else {
success &= file.delete(); if (file.isDown()) {
File localFile = new File(file.getStoragePath());
success &= localFile.delete();
if (success) {
file.setStoragePath(null);
saveFile(file);
} }
} }
} }
success &= folder.delete(); }
}
success &= localFolder.delete();
} }
return success; return success;
} }