diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a8c0f82c..5e2775b74 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,6 +40,12 @@ jobs: path: ~/.gradle/wrapper key: ${{ matrix.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + - name: Setup Gradle Wrapper Cache + uses: actions/cache@v3 + with: + path: ./it + key: minosoft-assets + - name: Build uses: gradle/gradle-build-action@v2 with: diff --git a/.gitignore b/.gitignore index 6cce2ea2c..0a3ea7c68 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ hs_err_pid*.log # Ignore Gradle build output directory build + +it/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24dd351cd..464a331b7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,6 +29,10 @@ cache: - "gradle/wrapper/gradle-wrapper.properties" paths: - .gradle_home/wrapper + - key: + "minosoft-assets" + paths: + - ./it build: stage: build diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt b/src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt index 076adaac9..eb205de75 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt @@ -38,7 +38,7 @@ internal object MinosoftSIT { Log.ASYNC_LOGGING = false RunConfiguration.VERBOSE_LOGGING = true RunConfiguration.APPLICATION_NAME = "Minosoft it" - RunConfiguration::HOME_DIRECTORY.forceSet(Path.of(System.getProperty("java.io.tmpdir"), "minosoft")) + RunConfiguration::HOME_DIRECTORY.forceSet(Path.of("./it")) RunConfiguration::CONFIG_DIRECTORY.forceSet(Path.of(System.getProperty("java.io.tmpdir"), "minosoft").resolve("conf")) RunConfiguration.PROFILES_HOT_RELOADING = false } diff --git a/src/main/java/de/bixilon/minosoft/config/profile/storage/StorageProfileManager.kt b/src/main/java/de/bixilon/minosoft/config/profile/storage/StorageProfileManager.kt index 69bec8d23..2f289c7c3 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/storage/StorageProfileManager.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/storage/StorageProfileManager.kt @@ -179,16 +179,20 @@ abstract class StorageProfileManager

: Iterable

, Identified { profile.lock.lock() storage.updating = true + unsafeUpdate(profile, data) + + storage.updating = false + // storage.invalid = false + profile.lock.unlock() + } + + fun unsafeUpdate(profile: P, data: ObjectNode) { val injectable = InjectableValues.Std() injectable.addValue(type.clazz, profile) reader .withValueToUpdate(profile) .with(injectable) .readValue

(data) - - storage.updating = false - // storage.invalid = false - profile.lock.unlock() } fun create(name: String): P { @@ -212,16 +216,17 @@ abstract class StorageProfileManager

: Iterable

, Identified { Log.log(LogMessageType.PROFILES, LogLevels.VERBOSE) { "Saving profile to $path" } profile.lock.acquire() + storage.invalid = false // do it before actually saving it. If the data changes while writing it gets saved another time storage.saved++ + val node = Jackson.MAPPER.valueToTree(profile) // TODO: cache jacksonType node.put(VERSION, latestVersion) val string = Jackson.MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(node) + val stream = FileOutputStream(path) stream.write(string.encodeNetwork()) stream.close() - storage.invalid = false - profile.lock.release() } @@ -250,7 +255,7 @@ abstract class StorageProfileManager

: Iterable

, Identified { } fun init() { - reader + reader // init lazy value } companion object {