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

Commit 4fdeb22d authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Add method to get SyncedFolder from DB from remote Path

- Add method getSyncedFolderByLocalPath(String path, Context context) in DbHelper.hava
- Add method getSyncedFolderByLocalPath(String path) in SyncedFolderDAO.java
parent d1f0b1bc
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -243,6 +243,16 @@ public final class DbHelper extends SQLiteOpenHelper {
        return result;
    }

    public static SyncedFolder getSyncedFolderByLocalPath(String localPath, Context context){
        SyncedFolderDAO dao = openSyncedFolderDAO(context, true);
        if(dao == null){
            return null;
        }
        SyncedFolder syncedFolder = dao.getSyncedFolderByLocalPath(localPath);
        dao.close();
        return syncedFolder;
    }

    /**
     * Set the lastModified value of SyncedFolder to 1.
     * The goal is to force to rescan it next time.
+11 −0
Original line number Diff line number Diff line
@@ -174,6 +174,17 @@ class SyncedFolderDAO {
        return result;
    }

    SyncedFolder getSyncedFolderByLocalPath(String localPath){
        Cursor cursor = mDB.query(TABLE_NAME, allColumns, LOCAL_PATH+" = "+localPath, new String[0], null, null, null);
        cursor.moveToFirst();
        SyncedFolder result = null;
        if ( !cursor.isAfterLast() ) {
            result = cursorToSyncedFolder(cursor);
        }
        cursor.close();
        return result;
    }

    /**
    * Create a syncedFolder object from data in cursor.
    * @param cursor cursor containing data to build syncedFolder