Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd3ba52e authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Merge branch '520-o-v2-file-deletion-to-remote-trash' into 'v1-oreo'

Removal of synchronized file on device, put remote file in the trash

See merge request !162
parents 95d75f1b 8dc22707
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ plugins {

def versionMajor = 1
def versionMinor = 2
def versionPatch = 3
def versionPatch = 4



+3 −2
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

package foundation.e.drive.FileObservers;

import static foundation.e.drive.models.SyncRequest.Type.REMOTE_DELETE;
import static foundation.e.drive.models.SyncRequest.Type.UPLOAD;

import android.content.Context;
@@ -222,8 +223,8 @@ public class FileEventListener {

        //If already in DB
        if (fileState.getScannable() > 0) {
            fileState.setScannable(0);
            DbHelper.manageSyncedFileStateDB(fileState, "UPDATE", appContext);
            SyncRequest deleteRequest = new SyncRequest(fileState, REMOTE_DELETE);
            this.sendSyncRequestToSynchronizationService(deleteRequest);
        }
    }

+3 −2
Original line number Diff line number Diff line
@@ -366,9 +366,10 @@ public final class DbHelper extends SQLiteOpenHelper {
     * @param context
     * @throws SQLiteException if database can't be open
     */
    public static void removeHiddenSyncedFileState(Context context) throws SQLiteException {
    public static void cleanSyncedFileStateTableAfterUpdate(Context context) throws SQLiteException {
        SyncedFileStateDAO dao = openSyncedFileStateDAO(context, true);
        dao.deleteHiddenFileState();
        dao.deleteHiddenFileStates();
        dao.updateUnscannableMediaFiles();
        dao.close();
    }
}
+16 −2
Original line number Diff line number Diff line
@@ -106,13 +106,27 @@ class SyncedFileStateDAO {


    /**
     * Remove SyncedFileState for hidden file (starting with '.')
     * Remove SyncedFileState for hidden files (starting with '.')
     * @return number of deleted input
     */
    public int deleteHiddenFileState() {
    public int deleteHiddenFileStates() {
        return mDB.delete(TABLE_NAME, FILE_NAME + " LIKE ?", new String[]{".%"});
    }

    /**
     * In previous version, when a synchronized file was removed, the DB value for scannable column
     * was set to "0"; Now we consider those entries has to be scannable set to "2" in order to let synchronization algo
     * to remove them
     * @return number of deleted input
     */
    public int updateUnscannableMediaFiles() {
        final ContentValues value = new ContentValues();
        value.put(SCANNABLE, SyncedFileState.DEVICE_SCANNABLE);
        final String whereClause = IS_MEDIA_TYPE + " =1 AND " + SCANNABLE + " ="+SyncedFileState.NOT_SCANNABLE;

        return mDB.update(TABLE_NAME, value, whereClause, null);
    }

    /**
     * Delete each syncedFileState which is bound to syncedFOlder with specified ID
     * @param folderId syncedFolder's id used as foreign key
+4 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
import java.io.File;

import foundation.e.drive.operations.DownloadFileOperation;
import foundation.e.drive.operations.RemoveFileOperation;
import foundation.e.drive.operations.UploadFileOperation;

/**
@@ -66,7 +67,7 @@ public class SyncWrapper {
                final File file = new File(sfs.getLocalPath());
                if (!file.exists()) {
                    operation = null;
                    Log.w(TAG, "createRemoteOperation: local file doesn't exist for upload");
                    Log.w(TAG, "createRemoteOperation: local file doesn't. Can't upload");
                    break;
                }
                operation = new UploadFileOperation(sfs, account, context);
@@ -78,6 +79,8 @@ public class SyncWrapper {
                        context);
                break;
            case REMOTE_DELETE:
                operation = new RemoveFileOperation(request.getSyncedFileState());
                break;
            default:
                operation = null;
                break;
Loading