Skip to content
Merged
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 @@ -1315,7 +1315,7 @@ public OCFile createFileInstance(FileEntity fileEntity) {
String metadataSize = fileEntity.getMetadataSize();
// Surprisingly JSON deserialization causes significant overhead.
// Avoid it in common, trivial cases (null/empty).
if (!(metadataSize == null || metadataSize.isEmpty() || JSON_NULL_STRING.equals(metadataSize))) {
if (metadataSize != null && !metadataSize.isEmpty() && !JSON_NULL_STRING.equalsIgnoreCase(metadataSize)) {
ImageDimension imageDimension = gson.fromJson(metadataSize, ImageDimension.class);
if (imageDimension != null) {
ocFile.setImageDimension(imageDimension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ public static Bitmap doResizedImageInBackground(OCFile file, FileDataStorageMana
}

// resized dimensions and set update thumbnail needed to false to prevent rendering loop
if (thumbnail != null) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We should not override actual image size with thumbnail size.

if (thumbnail != null && file.getImageDimension() == null) {
file.setImageDimension(new ImageDimension(thumbnail.getWidth(), thumbnail.getHeight()));
file.setUpdateThumbnailNeeded(false);
storageManager.saveFile(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,25 @@ private boolean parseMedia(long startDate, long endDate, List<Object> remoteFile
long filesAdded = 0, filesUpdated = 0, unchangedFiles = 0;

for (Object file : remoteFiles) {
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) file);
if (!(file instanceof RemoteFile remoteFile)) {
Log_OC.d(this, "object file is not remote file");
continue;
}

final OCFile existingFile = storageManager.getFileByDecryptedRemotePath(remoteFile.getRemotePath());

// add missing values from local storage to prevent override with null values
if (existingFile != null) {
final var imageDimension = existingFile.getImageDimension();
if (imageDimension != null) {
remoteFile.setImageDimension(existingFile.getImageDimension());
}
remoteFile.setLocalId(existingFile.getLocalId());
remoteFile.setCreationTimestamp(existingFile.getCreationTimestamp());
remoteFile.setUploadTimestamp(existingFile.getUploadTimestamp());
}

OCFile ocFile = FileStorageUtils.fillOCFile(remoteFile);

if (BuildConfig.DEBUG) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
Expand All @@ -167,6 +185,7 @@ private boolean parseMedia(long startDate, long endDate, List<Object> remoteFile
} else {
unchangedFiles++;
}

}

// existing files to remove
Expand Down
Loading