mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
Local files are protected against removal because of synchronization when out of the owncloud folder
This commit is contained in:
parent
34687403f4
commit
938c78466b
4 changed files with 7 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue