From: David A. Velasco Date: Tue, 31 Jul 2012 11:09:55 +0000 (+0200) Subject: Fixed lost of track of a downloaded file when it's tried to be renamed but the operat... X-Git-Tag: oc-android-1.4.3~221 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/9da82f797e2f5cef8ad84d078c1193f4823b9a36?ds=inline Fixed lost of track of a downloaded file when it's tried to be renamed but the operation fails --- diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java index a31541a7..f8f42061 100644 --- a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java +++ b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java @@ -856,6 +856,16 @@ public class FileDetailFragment extends SherlockFragment implements mHandler.post(new Runnable() { @Override public void run() { + // undo the local rename + if (mNew.isDown()) { + File f = new File(mNew.getStoragePath()); + if (!f.renameTo(new File(mOld.getStoragePath()))) { + // the local rename undoing failed; last chance: save the new local storage path in the old file + mFile.setStoragePath(mNew.getStoragePath()); + FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver()); + fdsm.saveFile(mFile); + } + } boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity; getActivity().dismissDialog((inDisplayActivity)? FileDisplayActivity.DIALOG_SHORT_WAIT : FileDetailActivity.DIALOG_SHORT_WAIT); try {