diff --git a/server/src/org/isoron/uhabits/sync/repository/FileRepository.kt b/server/src/org/isoron/uhabits/sync/repository/FileRepository.kt index c9ea5b500..07c793049 100644 --- a/server/src/org/isoron/uhabits/sync/repository/FileRepository.kt +++ b/server/src/org/isoron/uhabits/sync/repository/FileRepository.kt @@ -68,6 +68,6 @@ class FileRepository( } private fun String.toDataPath(): Path { - return basepath.resolve("${this.substring(0..1)}/${this.substring(2..3)}/$this") + return basepath.resolve("${this[0]}/${this[1]}/${this[2]}/${this[3]}/$this") } } \ No newline at end of file diff --git a/server/test/org/isoron/uhabits/sync/repository/FileRepositoryTest.kt b/server/test/org/isoron/uhabits/sync/repository/FileRepositoryTest.kt index c9d097778..047e0928e 100644 --- a/server/test/org/isoron/uhabits/sync/repository/FileRepositoryTest.kt +++ b/server/test/org/isoron/uhabits/sync/repository/FileRepositoryTest.kt @@ -39,11 +39,11 @@ class FileRepositoryTest { val original = SyncData(10, "Hello world") repo.put("abcdefg", original) - val metaPath = tempdir.resolve("ab/cd/abcdefg/version") + val metaPath = tempdir.resolve("a/b/c/d/abcdefg/version") assertTrue("$metaPath should exist", Files.exists(metaPath)) assertEquals("10", metaPath.toFile().readText()) - val dataPath = tempdir.resolve("ab/cd/abcdefg/content") + val dataPath = tempdir.resolve("a/b/c/d/abcdefg/content") assertTrue("$dataPath should exist", Files.exists(dataPath)) assertEquals("Hello world", dataPath.toFile().readText())