Fixed bug: renaming a folder could miss-update the storage path of children not-down files if a download file is in the folder

This commit is contained in:
David A. Velasco 2012-11-21 16:28:20 +01:00
parent 70c663008b
commit ccb796173b

View file

@ -533,12 +533,12 @@ public class FileDataStorageManager implements DataStorageManager {
/// 2. prepare a batch of update operations to change all the descendants /// 2. prepare a batch of update operations to change all the descendants
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(c.getCount()); ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(c.getCount());
ContentValues cv = new ContentValues();
int lengthOfOldPath = dir.getRemotePath().length(); int lengthOfOldPath = dir.getRemotePath().length();
String defaultSavePath = FileDownloader.getSavePath(mAccount.name); String defaultSavePath = FileDownloader.getSavePath(mAccount.name);
int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath; int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath;
if (c.moveToFirst()) { if (c.moveToFirst()) {
do { do {
ContentValues cv = new ContentValues(); // don't take the constructor out of the loop and clear the object
OCFile child = createFileInstance(c); OCFile child = createFileInstance(c);
cv.put(ProviderTableMeta.FILE_PATH, newPath + child.getRemotePath().substring(lengthOfOldPath)); cv.put(ProviderTableMeta.FILE_PATH, newPath + child.getRemotePath().substring(lengthOfOldPath));
if (child.getStoragePath() != null && child.getStoragePath().startsWith(defaultSavePath)) { if (child.getStoragePath() != null && child.getStoragePath().startsWith(defaultSavePath)) {