Compare commits

...
Author SHA1 Message Date
tobiasKaminsky 2492e15982 use local id from webdav
Signed-off-by: tobiasKaminsky <[email protected]>
2022-03-23 10:43:06 +01:00
7 changed files with 51 additions and 3 deletions

No files matched your search

@@ -13,6 +13,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
@@ -36,6 +37,12 @@ public class FileIT extends AbstractOnServerIT {
// folder exists
OCFile file = getStorageManager().getFileByPath(path);
assertTrue(file.isFolder());
assertEquals(path, file.getRemotePath());
assertNotNull(file.getLocalIdDirect());
assertEquals(
file.getLocalIdDirect(),
file.getRemoteId().substring(0, 8).replaceAll("^0*", "")
);
// cleanup
new RemoveFileOperation(file, false, account, false, targetContext, getStorageManager()).execute(client);
@@ -235,6 +235,7 @@ public class FileDataStorageManager {
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, ocFile.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PERMISSIONS, ocFile.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, ocFile.getRemoteId());
cv.put(ProviderTableMeta.FILE_LOCAL_ID, ocFile.getLocalId());
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, ocFile.isUpdateThumbnailNeeded());
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, ocFile.isDownloading());
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, ocFile.getEtagInConflict());
@@ -490,6 +491,7 @@ public class FileDataStorageManager {
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, folder.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PERMISSIONS, folder.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, folder.getRemoteId());
cv.put(ProviderTableMeta.FILE_LOCAL_ID, folder.getLocalId());
cv.put(ProviderTableMeta.FILE_FAVORITE, folder.isFavorite());
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, folder.isEncrypted());
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, folder.getUnreadCommentsCount());
@@ -524,6 +526,7 @@ public class FileDataStorageManager {
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(ProviderTableMeta.FILE_LOCAL_ID, file.getLocalId());
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded());
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
@@ -1014,6 +1017,7 @@ public class FileDataStorageManager {
ocFile.setSharedWithSharee(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_SHARED_WITH_SHAREE)) == 1);
ocFile.setPermissions(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_PERMISSIONS)));
ocFile.setRemoteId(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_REMOTE_ID)));
ocFile.setLocalId(getString(cursor, ProviderTableMeta.FILE_LOCAL_ID));
ocFile.setUpdateThumbnailNeeded(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1);
ocFile.setDownloading(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_IS_DOWNLOADING)) == 1);
ocFile.setEtagInConflict(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_ETAG_IN_CONFLICT)));
@@ -80,6 +80,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
private String etagOnServer;
private boolean sharedViaLink;
private String permissions;
private String localId; // The fileid locally on server
private String remoteId; // The fileid namespaced by the instance fileId, globally unique
private boolean updateThumbnailNeeded;
private boolean downloading;
@@ -149,6 +150,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
sharedViaLink = source.readInt() == 1;
permissions = source.readString();
remoteId = source.readString();
localId = source.readString();
updateThumbnailNeeded = source.readInt() == 1;
downloading = source.readInt() == 1;
etagInConflict = source.readString();
@@ -182,6 +184,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
dest.writeInt(sharedViaLink ? 1 : 0);
dest.writeString(permissions);
dest.writeString(remoteId);
dest.writeString(localId);
dest.writeInt(updateThumbnailNeeded ? 1 : 0);
dest.writeInt(downloading ? 1 : 0);
dest.writeString(etagInConflict);
@@ -447,6 +450,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
sharedViaLink = false;
permissions = null;
remoteId = null;
localId = null;
updateThumbnailNeeded = false;
downloading = false;
etagInConflict = null;
@@ -550,7 +554,9 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
*/
@Nullable
public String getLocalId() {
if (getRemoteId() != null) {
if (localId != null) {
return localId;
} else if (getRemoteId() != null) {
return getRemoteId().substring(0, 8).replaceAll("^0*", "");
} else {
return null;
@@ -768,6 +774,10 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
this.remoteId = remoteId;
}
public void setLocalId(String localId) {
this.localId = localId;
}
public void setUpdateThumbnailNeeded(boolean updateThumbnailNeeded) {
this.updateThumbnailNeeded = updateThumbnailNeeded;
}
@@ -819,4 +829,9 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
public void setRichWorkspace(String richWorkspace) {
this.richWorkspace = richWorkspace;
}
@VisibleForTesting
public String getLocalIdDirect() {
return localId;
}
}
@@ -35,7 +35,7 @@ import java.util.List;
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 62;
public static final int DB_VERSION = 63;
private ProviderMeta() {
// No instance
@@ -104,6 +104,7 @@ public class ProviderMeta {
public static final String FILE_SHARED_WITH_SHAREE = "shared_via_users";
public static final String FILE_PERMISSIONS = "permissions";
public static final String FILE_REMOTE_ID = "remote_id";
public static final String FILE_LOCAL_ID = "local_id";
public static final String FILE_UPDATE_THUMBNAIL = "update_thumbnail";
public static final String FILE_IS_DOWNLOADING = "is_downloading";
public static final String FILE_ETAG_IN_CONFLICT = "etag_in_conflict";
@@ -141,6 +142,7 @@ public class ProviderMeta {
FILE_SHARED_WITH_SHAREE,
FILE_PERMISSIONS,
FILE_REMOTE_ID,
FILE_LOCAL_ID,
FILE_UPDATE_THUMBNAIL,
FILE_IS_DOWNLOADING,
FILE_ETAG_IN_CONFLICT,
@@ -740,6 +740,7 @@ public class FileContentProvider extends ContentProvider {
+ ProviderTableMeta.FILE_SHARED_VIA_LINK + INTEGER
+ ProviderTableMeta.FILE_PERMISSIONS + " TEXT null,"
+ ProviderTableMeta.FILE_REMOTE_ID + " TEXT null,"
+ ProviderTableMeta.FILE_LOCAL_ID + " TEXT null,"
+ ProviderTableMeta.FILE_UPDATE_THUMBNAIL + INTEGER //boolean
+ ProviderTableMeta.FILE_IS_DOWNLOADING + INTEGER //boolean
+ ProviderTableMeta.FILE_FAVORITE + INTEGER // boolean
@@ -2457,6 +2458,24 @@ public class FileContentProvider extends ContentProvider {
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
if (oldVersion < 63 && newVersion >= 63) {
Log_OC.i(SQL, "Entering in the #63 add local id to files");
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCAL_ID + " TEXT ");
upgraded = true;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
}
}
}
@@ -221,6 +221,7 @@ public final class FileStorageUtils {
file.setEtag(remote.getEtag());
file.setPermissions(remote.getPermissions());
file.setRemoteId(remote.getRemoteId());
file.setLocalId(remote.getLocalId());
file.setFavorite(remote.isFavorite());
if (file.isFolder()) {
file.setEncrypted(remote.isEncrypted());
+1 -1
View File
@@ -6,7 +6,7 @@ buildscript {
daggerVersion = "2.41"
markwonVersion = "4.6.2"
prismVersion = "2.0.0"
androidLibraryVersion = "master-SNAPSHOT"
androidLibraryVersion = "fileId-SNAPSHOT"
mockitoVersion = "4.4.0"
mockitoKotlinVersion = "4.0.0"
mockkVersion = "1.12.3"