-
- /// 2. prepare a batch of update operations to change all the descendants
- ArrayList<ContentProviderOperation> operations =
- new ArrayList<ContentProviderOperation>(c.getCount());
- if (c.moveToFirst()) {
- int lengthOfOldPath = file.getRemotePath().length();
- String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);
- int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath;
- do {
- ContentValues cv = new ContentValues(); // keep construction in the loop
- OCFile child = createFileInstance(c);
+
+ } else {
+ c = getContentResolver().query(
+ ProviderTableMeta.CONTENT_URI,
+ null,
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
+ ProviderTableMeta.FILE_PATH + " LIKE ? ",
+ new String[] {
+ mAccount.name,
+ file.getRemotePath() + "%"
+ },
+ ProviderTableMeta.FILE_PATH + " ASC "
+ );
+ }
+
+ /// 2. prepare a batch of update operations to change all the descendants
+ ArrayList<ContentProviderOperation> operations =
+ new ArrayList<ContentProviderOperation>(c.getCount());
+ String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);
+ if (c.moveToFirst()) {
+ int lengthOfOldPath = file.getRemotePath().length();
+ int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath;
+ do {
+ ContentValues cv = new ContentValues(); // keep construction in the loop
+ OCFile child = createFileInstance(c);
+ cv.put(
+ ProviderTableMeta.FILE_PATH,
+ targetPath + child.getRemotePath().substring(lengthOfOldPath)
+ );
+ if (child.getStoragePath() != null &&
+ child.getStoragePath().startsWith(defaultSavePath)) {
+ // update link to downloaded content - but local move is not done here!