From b5b8815560bc786e1ab6247c6e07e5cb3f041a4e Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 16 Dec 2025 15:37:09 +0100 Subject: [PATCH] fix: use existing parent id for gallery search task Signed-off-by: alperozturk --- .../android/ui/asynctasks/GallerySearchTask.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/asynctasks/GallerySearchTask.java b/app/src/main/java/com/owncloud/android/ui/asynctasks/GallerySearchTask.java index 183d828c16f6..1da7d0aa9450 100644 --- a/app/src/main/java/com/owncloud/android/ui/asynctasks/GallerySearchTask.java +++ b/app/src/main/java/com/owncloud/android/ui/asynctasks/GallerySearchTask.java @@ -51,7 +51,7 @@ public GallerySearchTask(GalleryFragment photoFragment, } @Override - protected GallerySearchTask.Result doInBackground(Void... voids) { + protected Result doInBackground(Void... voids) { if (photoFragmentWeakReference.get() == null) { return new Result(false, false, -1); } @@ -98,7 +98,7 @@ protected GallerySearchTask.Result doInBackground(Void... voids) { } @Override - protected void onPostExecute(GallerySearchTask.Result result) { + protected void onPostExecute(Result result) { if (photoFragmentWeakReference.get() != null) { GalleryFragment photoFragment = photoFragmentWeakReference.get(); photoFragment.searchCompleted(result.emptySearch, result.lastTimestamp); @@ -147,9 +147,11 @@ private boolean parseMedia(long startDate, long endDate, List remoteFile 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) { @@ -160,8 +162,15 @@ private boolean parseMedia(long startDate, long endDate, List remoteFile remoteFile.setUploadTimestamp(existingFile.getUploadTimestamp()); } + // initialize oc file from remote file OCFile ocFile = FileStorageUtils.fillOCFile(remoteFile); + // since remote does not contains parent id information use existing file to prevent overriding parent id with 0 + if (existingFile != null) { + ocFile.setParentId(existingFile.getParentId()); + ocFile.setCreationTimestamp(existingFile.getCreationTimestamp()); + } + if (BuildConfig.DEBUG) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US); Log_OC.d(this,