From 0c673b6805e6fe086055e64371a8ad9fb786c0a2 Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Tue, 29 Aug 2023 04:07:01 +0530 Subject: [PATCH] Revert "Fix order of files for deletion criteria" This reverts commit 91dfdacdadcbb1d3dfb246240153f713f2e96ae3. --- trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt | 8 ++++---- .../src/main/java/com/amaze/trashbin/TrashBinMetadata.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt b/trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt index 6954d2b..de106a7 100644 --- a/trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt +++ b/trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt @@ -90,9 +90,9 @@ class TrashBin constructor( filesMetadata.forEach { totalSize += it.sizeBytes } - filesMetadata.sortedByDescending { + filesMetadata.sortedBy { trashBinFile -> - trashBinFile.deleteTime + trashBinFile.deleteTime?.times(-1) } writeMetadataAndTriggerCleanup(filesMetadata, totalSize, doTriggerCleanup) return true @@ -157,9 +157,9 @@ class TrashBin constructor( filesMetadata.forEach { totalSize += it.sizeBytes } - filesMetadata.sortedByDescending { + filesMetadata.sortedBy { trashBinFile -> - trashBinFile.deleteTime + trashBinFile.deleteTime?.times(-1) } writeMetadataAndTriggerCleanup(filesMetadata, totalSize, doTriggerCleanup) return true diff --git a/trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt b/trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt index 857d788..3ca73d0 100644 --- a/trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt +++ b/trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt @@ -52,7 +52,7 @@ data class TrashBinMetadata( fun getFilesWithDeletionCriteria(): List { var totalBytes = totalSize var numOfFiles = files.size - return files.sortedByDescending { it.deleteTime }.filter { + return files.sortedBy { it.deleteTime }.filter { file -> if (config.retentionNumOfFiles != TrashBinConfig.RETENTION_NUM_OF_FILES && numOfFiles > config.retentionNumOfFiles