Fixed lost of track of a downloaded file when it's tried to be renamed but the operat...
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 31 Jul 2012 11:09:55 +0000 (13:09 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 31 Jul 2012 11:09:55 +0000 (13:09 +0200)
src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java

index a31541a..f8f4206 100644 (file)
@@ -856,6 +856,16 @@ public class FileDetailFragment extends SherlockFragment implements
                 mHandler.post(new Runnable() {\r
                     @Override\r
                     public void run() {\r
+                        // undo the local rename\r
+                        if (mNew.isDown()) {\r
+                            File f = new File(mNew.getStoragePath());\r
+                            if (!f.renameTo(new File(mOld.getStoragePath()))) {\r
+                                // the local rename undoing failed; last chance: save the new local storage path in the old file\r
+                                mFile.setStoragePath(mNew.getStoragePath());\r
+                                FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
+                                fdsm.saveFile(mFile);\r
+                            }\r
+                        }\r
                         boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;\r
                         getActivity().dismissDialog((inDisplayActivity)? FileDisplayActivity.DIALOG_SHORT_WAIT : FileDetailActivity.DIALOG_SHORT_WAIT);\r
                         try {\r