Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ fun FileDataStorageManager.saveFolder(folder: OCFile, updatedFiles: List<OCFile>
"${filesToRemove.size} files to remove"
)

val removedChildren = filesToRemove.filter { it.parentId == folder.fileId && !isPendingOfflineCreation(it) }
val removedChildren = filesToRemove.filter { it.parentId == folder.fileId }
removedChildren.forEach { deleteLocalCopy(it) }

db.runInTransaction {
Expand All @@ -387,13 +387,14 @@ fun FileDataStorageManager.isPendingOfflineCreation(file: OCFile): Boolean {
return offlineOperationDao.getByPath(path)?.isCreate() == true
}

private fun FileDataStorageManager.upsertFolderContent(folder: OCFile, files: List<OCFile>) {
files.forEach { file ->
private fun FileDataStorageManager.upsertFolderContent(folder: OCFile, remoteFiles: List<OCFile>) {
remoteFiles.forEach { file ->
val existingFile = findExistingFile(file)
val entity = file.toFileEntity(user.accountName).copy(
val rEntity = file.toFileEntity(user.accountName)
val entity = rEntity.copy(
id = existingFile?.id,
parent = folder.fileId,
mountType = existingFile?.mountType
mountType = rEntity.mountType ?: existingFile?.mountType
)

val insertedRowId = fileDao.upsert(entity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fun OCFile.toFileEntity(accountName: String): FileEntity = FileEntity(
isEncrypted = isEncrypted.toInt(),
etagInConflict = etagInConflict,
sharedWithSharee = isSharedWithSharee.toInt(),
mountType = null,
mountType = mountType?.ordinal,
hasPreview = isPreviewAvailable.toInt(),
unreadCommentsCount = unreadCommentsCount,
ownerId = ownerId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ private ContentValues createContentValuesBase(OCFile fileOrFolder) {
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, fileOrFolder.getEtagOnServer());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, fileOrFolder.isSharedViaLink() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, fileOrFolder.isSharedWithSharee() ? 1 : 0);
if (fileOrFolder.getMountType() != null) {
cv.put(ProviderTableMeta.FILE_MOUNT_TYPE, fileOrFolder.getMountType().ordinal());
}
cv.put(ProviderTableMeta.FILE_PERMISSIONS, fileOrFolder.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, fileOrFolder.getRemoteId());
cv.put(ProviderTableMeta.FILE_LOCAL_ID, fileOrFolder.getLocalId());
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/owncloud/android/datamodel/OCFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ public void setFileName(String name) {
/**
* Used internally. Reset all file properties
*/
@SuppressFBWarnings("ENMI_NULL_ENUM_VALUE")
private void resetData() {
fileId = -1;
remotePath = null;
Expand Down Expand Up @@ -521,7 +522,7 @@ private void resetData() {
hidden = false;
encrypted = false;
readOnly = false;
mountType = WebdavEntry.MountType.INTERNAL;
mountType = null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you mark getMountType via @Nullable and check every call?

richWorkspace = "";
firstShareTimestamp = 0;
locked = false;
Expand Down Expand Up @@ -705,7 +706,7 @@ private boolean hasPermission(String permission) {
}

public Integer getFileOverlayIconId(boolean isAutoUploadFolder) {
if (WebdavEntry.MountType.GROUP == mountType || mounted()) {
if (WebdavEntry.MountType.GROUP == mountType) {
return R.drawable.ic_folder_overlay_account_group;
} else if (sharedViaLink && !encrypted) {
return R.drawable.ic_folder_overlay_link;
Expand Down
Loading