소스 검색

Local files are protected against removal because of synchronization when out of the owncloud folder

David A. Velasco 12 년 전
부모
커밋
938c78466b

+ 1 - 1
src/com/owncloud/android/datamodel/DataStorageManager.java

@@ -37,5 +37,5 @@ public interface DataStorageManager {
 
     public Vector<OCFile> getDirectoryContent(OCFile f);
     
-    public void removeFile(OCFile file);
+    public void removeFile(OCFile file, boolean removeLocalCopy);
 }

+ 2 - 2
src/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -399,7 +399,7 @@ public class FileDataStorageManager implements DataStorageManager {
         return file;
     }
     
-    public void removeFile(OCFile file) {
+    public void removeFile(OCFile file, boolean removeLocalCopy) {
         Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
         if (getContentProvider() != null) {
             try {
@@ -414,7 +414,7 @@ public class FileDataStorageManager implements DataStorageManager {
                                         ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
                                         new String[]{mAccount.name});
         }
-        if (file.isDown()) {
+        if (file.isDown() && removeLocalCopy) {
             new File(file.getStoragePath()).delete();
         }
     }

+ 2 - 1
src/com/owncloud/android/syncadapter/FileSyncAdapter.java

@@ -210,11 +210,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             Vector<OCFile> files = getStorageManager().getDirectoryContent(
                     getStorageManager().getFileById(parentId));
             OCFile file;
+            String currentSavePath = FileDownloader.getSavePath(mAccount.name);
             for (int i=0; i < files.size(); ) {
                 file = files.get(i);
                 if (file.getLastSyncDate() != mCurrentSyncTime) {
                     Log.v(TAG, "removing file: " + file);
-                    getStorageManager().removeFile(file);
+                    getStorageManager().removeFile(file, (file.isDown() && file.getStoragePath().startsWith(currentSavePath)));
                     files.remove(i);
                 } else {
                     i++;

+ 2 - 2
src/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -842,7 +842,7 @@ public class FileDetailFragment extends SherlockFragment implements
             
             if (success) {
                 FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
-                fdsm.removeFile(mOld);
+                fdsm.removeFile(mOld, false);
                 fdsm.saveFile(mNew);
                 mFile = mNew;
                 mHandler.post(new Runnable() {
@@ -1008,7 +1008,7 @@ public class FileDetailFragment extends SherlockFragment implements
             
             if (success) {
                 FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
-                fdsm.removeFile(mFileToRemove);
+                fdsm.removeFile(mFileToRemove, true);
                 mHandler.post(new Runnable() {
                     @Override
                     public void run() {