Loading app/src/main/java/foundation/e/drive/services/ObserverService.java +9 −15 Original line number Diff line number Diff line Loading @@ -498,26 +498,20 @@ public class ObserverService extends Service implements OnRemoteOperationListene final File file = new File( syncedFileStates.get(i).getLocalPath() ); //Try to remove local file boolean fileExists = file.exists(); if (fileExists) { Log.d(TAG, file.getName()+" exists *1"); //delete file if (file.exists()) { int rowAffected = getContentResolver().delete(MediaStore.Files.getContentUri("external"), MediaStore.Files.FileColumns.DATA + "=?", new String[]{CommonUtils.getLocalPath(file)}); Log.d(TAG, "deleted rows by mediastore : " + rowAffected); //sometimes (it seems to be relative to file's type) mediastore don't remove local file from storage fileExists = !file.delete(); if (!file.delete()) { //May throw SecurityException or IOException Log.w(TAG, "local file (" + file.getName() + ") removal failed."); continue; } } //if it succeed, remove syncedFileState in DB if (!fileExists) { //It means that file has been correctly deleted from device. So update DB. if (DbHelper.manageSyncedFileStateDB(syncedFileState, "DELETE", this) <= 0) { Log.e(TAG, "SyncedFileState row hasn't been deleted from DB"); } } else { Log.w(TAG, "local file:" + file.getName() + " still exist and can't be remove"); Log.e(TAG, "Failed to remove " + file.getName() + " from DB"); } } } Loading Loading
app/src/main/java/foundation/e/drive/services/ObserverService.java +9 −15 Original line number Diff line number Diff line Loading @@ -498,26 +498,20 @@ public class ObserverService extends Service implements OnRemoteOperationListene final File file = new File( syncedFileStates.get(i).getLocalPath() ); //Try to remove local file boolean fileExists = file.exists(); if (fileExists) { Log.d(TAG, file.getName()+" exists *1"); //delete file if (file.exists()) { int rowAffected = getContentResolver().delete(MediaStore.Files.getContentUri("external"), MediaStore.Files.FileColumns.DATA + "=?", new String[]{CommonUtils.getLocalPath(file)}); Log.d(TAG, "deleted rows by mediastore : " + rowAffected); //sometimes (it seems to be relative to file's type) mediastore don't remove local file from storage fileExists = !file.delete(); if (!file.delete()) { //May throw SecurityException or IOException Log.w(TAG, "local file (" + file.getName() + ") removal failed."); continue; } } //if it succeed, remove syncedFileState in DB if (!fileExists) { //It means that file has been correctly deleted from device. So update DB. if (DbHelper.manageSyncedFileStateDB(syncedFileState, "DELETE", this) <= 0) { Log.e(TAG, "SyncedFileState row hasn't been deleted from DB"); } } else { Log.w(TAG, "local file:" + file.getName() + " still exist and can't be remove"); Log.e(TAG, "Failed to remove " + file.getName() + " from DB"); } } } Loading