Local files are protected against removal because of synchronization when out of the owncloud folder

This commit is contained in:
David A. Velasco 2012-08-22 12:50:06 +02:00
parent 34687403f4
commit 938c78466b
4 changed files with 7 additions and 6 deletions

View file

@ -37,5 +37,5 @@ public interface DataStorageManager {
public Vector<OCFile> getDirectoryContent(OCFile f);
public void removeFile(OCFile file);
public void removeFile(OCFile file, boolean removeLocalCopy);
}

View file

@ -399,7 +399,7 @@ public class FileDataStorageManager implements DataStorageManager {
return file;
}
public void removeFile(OCFile file) {
public void removeFile(OCFile file, boolean removeLocalCopy) {
Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
if (getContentProvider() != null) {
try {
@ -414,7 +414,7 @@ public class FileDataStorageManager implements DataStorageManager {
ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
new String[]{mAccount.name});
}
if (file.isDown()) {
if (file.isDown() && removeLocalCopy) {
new File(file.getStoragePath()).delete();
}
}

View file

@ -210,11 +210,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
Vector<OCFile> files = getStorageManager().getDirectoryContent(
getStorageManager().getFileById(parentId));
OCFile file;
String currentSavePath = FileDownloader.getSavePath(mAccount.name);
for (int i=0; i < files.size(); ) {
file = files.get(i);
if (file.getLastSyncDate() != mCurrentSyncTime) {
Log.v(TAG, "removing file: " + file);
getStorageManager().removeFile(file);
getStorageManager().removeFile(file, (file.isDown() && file.getStoragePath().startsWith(currentSavePath)));
files.remove(i);
} else {
i++;

View file

@ -842,7 +842,7 @@ public class FileDetailFragment extends SherlockFragment implements
if (success) {
FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
fdsm.removeFile(mOld);
fdsm.removeFile(mOld, false);
fdsm.saveFile(mNew);
mFile = mNew;
mHandler.post(new Runnable() {
@ -1008,7 +1008,7 @@ public class FileDetailFragment extends SherlockFragment implements
if (success) {
FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
fdsm.removeFile(mFileToRemove);
fdsm.removeFile(mFileToRemove, true);
mHandler.post(new Runnable() {
@Override
public void run() {