X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/133e89d49559be9ead2449c2bdc7cd38ec23a71b..c2abbaaedb69dba35866a48b745b68f3519cbca1:/src/com/owncloud/android/datamodel/FileDataStorageManager.java diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index d84eb2a0..9933e360 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -25,12 +25,12 @@ import java.util.Iterator; import java.util.List; import java.util.Vector; -import com.owncloud.android.DisplayUtils; import com.owncloud.android.Log_OC; -import com.owncloud.android.db.ProviderMeta; +import com.owncloud.android.MainApp; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; import com.owncloud.android.utils.FileStorageUtils; + import android.accounts.Account; import android.content.ContentProviderClient; import android.content.ContentProviderOperation; @@ -235,6 +235,12 @@ public class FileDataStorageManager implements DataStorageManager { if (fileExists(file.getRemotePath())) { OCFile oldFile = getFileByPath(file.getRemotePath()); file.setFileId(oldFile.getFileId()); + + if (file.isDirectory()) { + cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength()); + file.setFileLength(oldFile.getFileLength()); + } + operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI). withValues(cv). withSelection( ProviderTableMeta._ID + "=?", @@ -245,9 +251,14 @@ public class FileDataStorageManager implements DataStorageManager { OCFile oldFile = getFileById(file.getFileId()); if (file.getStoragePath() == null && oldFile.getStoragePath() != null) file.setStoragePath(oldFile.getStoragePath()); - if (!file.isDirectory()); - cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); - + + if (!file.isDirectory()) + cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); + else { + cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength()); + file.setFileLength(oldFile.getFileLength()); + } + operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI). withValues(cv). withSelection( ProviderTableMeta._ID + "=?", @@ -263,7 +274,7 @@ public class FileDataStorageManager implements DataStorageManager { ContentProviderResult[] results = null; try { if (getContentResolver() != null) { - results = getContentResolver().applyBatch(ProviderMeta.AUTHORITY_FILES, operations); + results = getContentResolver().applyBatch(MainApp.getAuthority(), operations); } else { results = getContentProvider().applyBatch(operations); @@ -546,16 +557,16 @@ public class FileDataStorageManager implements DataStorageManager { try { c = getContentProvider().query(ProviderTableMeta.CONTENT_URI, null, - ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ?", - new String[] { mAccount.name, dir.getRemotePath() + "%" }, null); + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ", + new String[] { mAccount.name, dir.getRemotePath() + "%" }, ProviderTableMeta.FILE_PATH + " ASC "); } catch (RemoteException e) { Log_OC.e(TAG, e.getMessage()); } } else { c = getContentResolver().query(ProviderTableMeta.CONTENT_URI, null, - ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ?", - new String[] { mAccount.name, dir.getRemotePath() + "%" }, null); + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ", + new String[] { mAccount.name, dir.getRemotePath() + "%" }, ProviderTableMeta.FILE_PATH + " ASC "); } /// 2. prepare a batch of update operations to change all the descendants @@ -583,7 +594,7 @@ public class FileDataStorageManager implements DataStorageManager { /// 3. apply updates in batch try { if (getContentResolver() != null) { - getContentResolver().applyBatch(ProviderMeta.AUTHORITY_FILES, operations); + getContentResolver().applyBatch(MainApp.getAuthority(), operations); } else { getContentProvider().applyBatch(operations); @@ -665,7 +676,6 @@ public class FileDataStorageManager implements DataStorageManager { while (parentId != 0) { - Log_OC.d(TAG, "parent = " + parentId); // Update the size of the parent calculateFolderSize(parentId);