X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/c6b553f635c7cbb4f21d41a6fa82e204447c16cf..9da82f797e2f5cef8ad84d078c1193f4823b9a36:/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java diff --git a/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java b/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java index c732f59b..f0d0db25 100644 --- a/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java +++ b/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java @@ -27,6 +27,7 @@ import java.util.Vector; import eu.alefzero.owncloud.db.ProviderMeta; import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta; +import eu.alefzero.owncloud.files.services.FileDownloader; import android.accounts.Account; import android.content.ContentProviderClient; import android.content.ContentProviderOperation; @@ -111,11 +112,12 @@ public class FileDataStorageManager implements DataStorageManager { cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0); if (fileExists(file.getRemotePath())) { - OCFile tmpfile = getFileByPath(file.getRemotePath()); - file.setStoragePath(tmpfile.getStoragePath()); + OCFile oldFile = getFileByPath(file.getRemotePath()); + if (file.getStoragePath() == null && oldFile.getStoragePath() != null) + file.setStoragePath(oldFile.getStoragePath()); if (!file.isDirectory()); cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); - file.setFileId(tmpfile.getFileId()); + file.setFileId(oldFile.getFileId()); overriden = true; if (getContentResolver() != null) { @@ -377,8 +379,7 @@ public class FileDataStorageManager implements DataStorageManager { .getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH))); if (file.getStoragePath() == null) { // try to find existing file and bind it with current account - File sdCard = Environment.getExternalStorageDirectory(); - File f = new File(sdCard.getAbsolutePath() + "/owncloud/" + mAccount.name + file.getRemotePath()); + File f = new File(FileDownloader.getSavePath(mAccount.name) + file.getRemotePath()); if (f.exists()) file.setStoragePath(f.getAbsolutePath()); } @@ -412,7 +413,7 @@ public class FileDataStorageManager implements DataStorageManager { ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?", new String[]{mAccount.name}); } - if (file.getStoragePath() != null) { + if (file.isDown()) { new File(file.getStoragePath()).delete(); } }