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 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;
|
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());
|
Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
|
||||||
if (getContentProvider() != null) {
|
if (getContentProvider() != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -414,7 +414,7 @@ public class FileDataStorageManager implements DataStorageManager {
|
||||||
ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
|
ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
|
||||||
new String[]{mAccount.name});
|
new String[]{mAccount.name});
|
||||||
}
|
}
|
||||||
if (file.isDown()) {
|
if (file.isDown() && removeLocalCopy) {
|
||||||
new File(file.getStoragePath()).delete();
|
new File(file.getStoragePath()).delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,11 +210,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||||
Vector<OCFile> files = getStorageManager().getDirectoryContent(
|
Vector<OCFile> files = getStorageManager().getDirectoryContent(
|
||||||
getStorageManager().getFileById(parentId));
|
getStorageManager().getFileById(parentId));
|
||||||
OCFile file;
|
OCFile file;
|
||||||
|
String currentSavePath = FileDownloader.getSavePath(mAccount.name);
|
||||||
for (int i=0; i < files.size(); ) {
|
for (int i=0; i < files.size(); ) {
|
||||||
file = files.get(i);
|
file = files.get(i);
|
||||||
if (file.getLastSyncDate() != mCurrentSyncTime) {
|
if (file.getLastSyncDate() != mCurrentSyncTime) {
|
||||||
Log.v(TAG, "removing file: " + file);
|
Log.v(TAG, "removing file: " + file);
|
||||||
getStorageManager().removeFile(file);
|
getStorageManager().removeFile(file, (file.isDown() && file.getStoragePath().startsWith(currentSavePath)));
|
||||||
files.remove(i);
|
files.remove(i);
|
||||||
} else {
|
} else {
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -842,7 +842,7 @@ public class FileDetailFragment extends SherlockFragment implements
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
|
FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
|
||||||
fdsm.removeFile(mOld);
|
fdsm.removeFile(mOld, false);
|
||||||
fdsm.saveFile(mNew);
|
fdsm.saveFile(mNew);
|
||||||
mFile = mNew;
|
mFile = mNew;
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
|
@ -1008,7 +1008,7 @@ public class FileDetailFragment extends SherlockFragment implements
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
|
FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());
|
||||||
fdsm.removeFile(mFileToRemove);
|
fdsm.removeFile(mFileToRemove, true);
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
Loading…
Reference in a new issue