X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/435b31ba4f3597cc7a43270cd4a54fb0180956c1..5f61cb15552eb2fda01716078a9191b88cebf764:/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 80072bbc..3733234a 100644 --- a/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java +++ b/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java @@ -18,6 +18,8 @@ package eu.alefzero.owncloud.datamodel; +import java.io.File; +import java.util.Collections; import java.util.Vector; import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta; @@ -93,12 +95,13 @@ public class FileDataStorageManager implements DataStorageManager { cv.put(ProviderTableMeta.FILE_NAME, file.getFileName()); if (file.getParentId() != 0) cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId()); - cv.put(ProviderTableMeta.FILE_PATH, file.getPath()); + cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath()); cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name); + cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDate()); - if (fileExists(file.getPath())) { - OCFile tmpfile = getFileByPath(file.getPath()); + if (fileExists(file.getRemotePath())) { + OCFile tmpfile = getFileByPath(file.getRemotePath()); file.setStoragePath(tmpfile.getStoragePath()); cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); file.setFileId(tmpfile.getFileId()); @@ -204,6 +207,9 @@ public class FileDataStorageManager implements DataStorageManager { } c.close(); + + Collections.sort(ret); + return ret; } return null; @@ -283,8 +289,30 @@ public class FileDataStorageManager implements DataStorageManager { .getColumnIndex(ProviderTableMeta.FILE_CREATION))); file.setModificationTimestamp(c.getLong(c .getColumnIndex(ProviderTableMeta.FILE_MODIFIED))); + file.setLastSyncDate(c.getLong(c + .getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE))); } return file; } + + public void removeFile(OCFile file) { + Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId()); + if (getContentProvider() != null) { + try { + getContentProvider().delete(file_uri, + ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?", + new String[]{mAccount.name}); + } catch (RemoteException e) { + e.printStackTrace(); + } + } else { + getContentResolver().delete(file_uri, + ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?", + new String[]{mAccount.name}); + } + if (file.getStoragePath() != null) { + new File(file.getStoragePath()).delete(); + } + } }