projects
/
pub
/
Android
/
ownCloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug fixed (and some refactoring): crash on local removal of a folder
[pub/Android/ownCloud.git]
/
src
/
com
/
owncloud
/
android
/
datamodel
/
FileDataStorageManager.java
diff --git
a/src/com/owncloud/android/datamodel/FileDataStorageManager.java
b/src/com/owncloud/android/datamodel/FileDataStorageManager.java
index
dbe6938
..
3f0d69f
100644
(file)
--- a/
src/com/owncloud/android/datamodel/FileDataStorageManager.java
+++ b/
src/com/owncloud/android/datamodel/FileDataStorageManager.java
@@
-346,7
+346,9
@@
public class FileDataStorageManager {
).withSelection(where, whereArgs).build());
if (file.isDown()) {
).withSelection(where, whereArgs).build());
if (file.isDown()) {
- new File(file.getStoragePath()).delete();
+ String path = file.getStoragePath();
+ new File(path).delete();
+ triggerMediaScan(path); // notify MediaScanner about removed file
}
}
}
}
}
}
@@
-484,8
+486,12
@@
public class FileDataStorageManager {
}
success &= (deleted > 0);
}
}
success &= (deleted > 0);
}
- if (removeLocalCopy && file.isDown() && file.getStoragePath() != null && success) {
- success = new File(file.getStoragePath()).delete();
+ String localPath = file.getStoragePath();
+ if (removeLocalCopy && file.isDown() && localPath != null && success) {
+ success = new File(localPath).delete();
+ if (success) {
+ triggerMediaScan(localPath);
+ }
if (!removeDBData && success) {
// maybe unnecessary, but should be checked TODO remove if unnecessary
file.setStoragePath(null);
if (!removeDBData && success) {
// maybe unnecessary, but should be checked TODO remove if unnecessary
file.setStoragePath(null);
@@
-542,11
+548,13
@@
public class FileDataStorageManager {
success &= removeLocalFolder(file);
} else {
if (file.isDown()) {
success &= removeLocalFolder(file);
} else {
if (file.isDown()) {
+ String path = file.getStoragePath();
File localFile = new File(file.getStoragePath());
success &= localFile.delete();
if (success) {
file.setStoragePath(null);
saveFile(file);
File localFile = new File(file.getStoragePath());
success &= localFile.delete();
if (success) {
file.setStoragePath(null);
saveFile(file);
+ triggerMediaScan(path); // notify MediaScanner about removed file
}
}
}
}
}
}
@@
-568,7
+576,9
@@
public class FileDataStorageManager {
if (localFile.isDirectory()) {
success &= removeLocalFolder(localFile);
} else {
if (localFile.isDirectory()) {
success &= removeLocalFolder(localFile);
} else {
+ String path = localFile.getAbsolutePath();
success &= localFile.delete();
success &= localFile.delete();
+ triggerMediaScan(path); // notify MediaScanner about removed file
}
}
}
}
}
}
@@
-788,14
+798,10
@@
public class FileDataStorageManager {
Log_OC.d(TAG, "Local file RENAMED : " + renamed);
// Notify MediaScanner about removed file
Log_OC.d(TAG, "Local file RENAMED : " + renamed);
// Notify MediaScanner about removed file
- Intent intent1 = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
- intent1.setData(Uri.fromFile(new File(file.getStoragePath())));
- MainApp.getAppContext().sendBroadcast(intent1);
+ triggerMediaScan(file.getStoragePath());
// Notify MediaScanner about new file/folder
// Notify MediaScanner about new file/folder
- Intent intent2 = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
- intent2.setData(Uri.fromFile(new File(defaultSavePath + targetPath)));
- MainApp.getAppContext().sendBroadcast(intent2);
+ triggerMediaScan(defaultSavePath + targetPath);
Log_OC.d(TAG, "uri old: " + file.getStoragePath());
Log_OC.d(TAG, "uri new: " + defaultSavePath + targetPath);
Log_OC.d(TAG, "uri old: " + file.getStoragePath());
Log_OC.d(TAG, "uri new: " + defaultSavePath + targetPath);
@@
-1414,7
+1420,7
@@
public class FileDataStorageManager {
path = path + FileUtils.PATH_SEPARATOR;
}
path = path + FileUtils.PATH_SEPARATOR;
}
- // Update OCFile with data from share: ShareByLink
�and publicLink?
+ // Update OCFile with data from share: ShareByLink
and publicLink
OCFile file = getFileByPath(path);
if (file != null) {
if (share.getShareType().equals(ShareType.PUBLIC_LINK)) {
OCFile file = getFileByPath(path);
if (file != null) {
if (share.getShareType().equals(ShareType.PUBLIC_LINK)) {
@@
-1561,4
+1567,10
@@
public class FileDataStorageManager {
//}
}
//}
}
+ public void triggerMediaScan(String path) {
+ Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ intent.setData(Uri.fromFile(new File(path)));
+ MainApp.getAppContext().sendBroadcast(intent);
+ }
+
}
}