X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/eaa3b1ef566ec3301dc648e6e57b39af7915392f..0f39ff841a65d49778abf915b8730bce734bd960:/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 abaafa5f..3f0d69f2 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -347,12 +347,8 @@ public class FileDataStorageManager { if (file.isDown()) { String path = file.getStoragePath(); - new File(file.getStoragePath()).delete(); - - // Notify MediaScanner about removed file - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(new File(path))); - MainApp.getAppContext().sendBroadcast(intent); + new File(path).delete(); + triggerMediaScan(path); // notify MediaScanner about removed file } } } @@ -490,8 +486,12 @@ public class FileDataStorageManager { } 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); @@ -554,11 +554,7 @@ public class FileDataStorageManager { if (success) { file.setStoragePath(null); saveFile(file); - - // Notify MediaScanner about removed file - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(new File(path))); - MainApp.getAppContext().sendBroadcast(intent); + triggerMediaScan(path); // notify MediaScanner about removed file } } } @@ -582,11 +578,7 @@ public class FileDataStorageManager { } else { String path = localFile.getAbsolutePath(); success &= localFile.delete(); - - // Notify MediaScanner about removed file - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(new File(path))); - MainApp.getAppContext().sendBroadcast(intent); + triggerMediaScan(path); // notify MediaScanner about removed file } } } @@ -806,14 +798,10 @@ public class FileDataStorageManager { 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 - 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); @@ -1579,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); + } + }