import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.utils.FileStorageUtils;
-
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
+import android.content.Intent;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.net.Uri;
).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
}
}
}
}
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);
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);
+ triggerMediaScan(path); // notify MediaScanner about removed file
}
}
}
if (localFile.isDirectory()) {
success &= removeLocalFolder(localFile);
} else {
+ String path = localFile.getAbsolutePath();
success &= localFile.delete();
+ triggerMediaScan(path); // notify MediaScanner about removed file
}
}
}
}
Log_OC.d(TAG, "Local file RENAMED : " + renamed);
+ // Notify MediaScanner about removed file
+ triggerMediaScan(file.getStoragePath());
+
+ // Notify MediaScanner about new file/folder
+ triggerMediaScan(defaultSavePath + targetPath);
+
+ Log_OC.d(TAG, "uri old: " + file.getStoragePath());
+ Log_OC.d(TAG, "uri new: " + defaultSavePath + targetPath);
}
}
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)) {
//}
}
+ 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);
+ }
+
}