Skip to content

Commit

Permalink
SystemCleaner: Remove block/inode size limit when checking for empty …
Browse files Browse the repository at this point in the history
…directories
  • Loading branch information
d4rken committed Sep 7, 2024
1 parent 81e75e4 commit 7236162
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ class EmptyDirectoryFilter @Inject constructor(
return null
}

if (item.size > 65536) return null

// Check for nested empty directories
val content = item.lookupFiles(gatewaySwitch)
return when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ abstract class SystemCleanerFilterTest : BaseTest() {
data object Primary : Area
data object Secondary : Area
}

data class Size(val size: Long) : Flag
}

suspend fun pos(location: Type, path: String, vararg flags: Flag) {
Expand Down Expand Up @@ -413,6 +415,8 @@ abstract class SystemCleanerFilterTest : BaseTest() {
}
require(!(flagsCollection.contains(Flag.Dir) && flagsCollection.contains(Flag.File))) { "Can't be both file and dir." }

val sizeFlag = flags.filterIsInstance<Flag.Size>().singleOrNull()

val mockPath = area.path.child(targetPath)
val mockLookup = when (area.path.pathType) {
APath.PathType.LOCAL -> LocalPathLookup(
Expand All @@ -425,6 +429,7 @@ abstract class SystemCleanerFilterTest : BaseTest() {
throw IllegalArgumentException("Unknown file type")
},
size = when {
sizeFlag != null -> sizeFlag.size
flagsCollection.contains(Flag.Dir) -> 512L
else -> 1024 * 1024L
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,13 @@ class EmptyDirectoryFilterTest : SystemCleanerFilterTest() {

confirm(create())
}

@Test fun `empty directories - with large node sizes`() = runTest {
neg(SDCARD, "0", Flag.File)
pos(SDCARD, "1", Flag.Dir, Flag.Size(262144))
pos(SDCARD, "2", Flag.Dir, Flag.Size(524288))
pos(SDCARD, "3", Flag.Dir, Flag.Size(1048576))

confirm(create())
}
}

0 comments on commit 7236162

Please sign in to comment.