Files
justbackup/build.gradle
T
iceBear67 34f7d15566 overhaul thread model and backup reliability
Thread model:
  - replace the IOState CAS state machine with a StampedLock: region IO
    (RegionFileStorage.write/flush, now both guarded via @WrapMethod) holds
    the read lock, backups hold the write lock; the old witness-restore
    pattern could wedge the state permanently
  - run saveEverything on the main thread (was called from the backup
    executor), with shutdown-aware waiting; skip autoSave/saveEverything
    while a backup holds the write lock so the main thread never blocks
  - broadcast player messages from the main thread, honor `broadcast`

  Backup correctness:
  - watcher reported the parent directory instead of the changed file, so
    every incremental backup was empty; change sets are now deduplicated,
    atomically drained and merged back on failure; OVERFLOW forces a full
    backup; watch roots are re-registered when their inode changes (world
    format conversion orphaned the watches)
  - fix the region reassembly pipeline: zlib was "decompressed" with
    DeflaterInputStream, writeChunk dropped the 5-byte chunk header,
    the length field was off by one, coordinates were transposed, and
    sector padding was wrong on 4096-byte multiples — every reassembled
    chunk in old bundles is unrecoverable garbage
  - full backups now collect the file list after saving, off-thread

  New features:
  - reflink (FICLONE) staging via FFM: on CoW filesystems the write lock
    is only held while cloning, packing/uploading runs unlocked
  - chained restore: restoring an incremental automatically applies its
    full base and every incremental in between, in order
  - generation-based rotation implementing keepBackups; whole generations
    are deleted so an incremental never loses its base
  - Backup records carry subject/createdAt/incremental for chaining

  Reliability:
  - atomic index persistence (tmp + ATOMIC_MOVE), ConcurrentHashMap for
    the tracked-backup index, fsync bundles before storing
  - BundleReader: overlay extraction for chains, zip-slip guard, fix
    reversed createSymbolicLink args, EOF instead of infinite loop on
    truncated bundles
  - LocalBackupStrategy.deleteBackup compared the wrong field and could
    never delete; S3 retries now catch SdkException (retry was dead code),
    drop ifNoneMatch for idempotent retries
  - ordered shutdown: SERVER_STOPPING awaits in-flight backups before the
    final world save; SERVER_STOPPED runs restore, closes storage and
    cleans the temp dir with isolated error handling
  - fix /backup suspend being registered under /backup create

  Tests: region round-trip byte-comparison, BundleReader overlay/zip-slip/
  symlink/truncation, backup chain resolution and rotation.

  Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 19:35:43 +08:00

135 lines
4.0 KiB
Groovy

plugins {
id 'net.fabricmc.fabric-loom' version "${loom_version}"
id 'maven-publish'
id("io.freefair.lombok") version "9.0.0-rc2"
id("com.gradleup.shadow") version '9.1.0'
}
allprojects {
apply plugin: "io.freefair.lombok"
apply plugin: 'java'
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
// Lombok 1.18.40+ is required for JDK 25 (class file major version 69).
lombok {
version = "1.18.46"
}
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
name = "Kalculos"
url = "https://repo.sfclub.cc/snapshots"
}
mavenCentral()
}
}
loom {
splitEnvironmentSourceSets()
mods {
"justbackup" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 25
}
}
dependencies {
// To change the versions see the gradle.properties file
// Minecraft 26.1+ is unobfuscated, so no mappings are required.
minecraft "com.mojang:minecraft:${project.minecraft_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// https://mvnrepository.com/artifact/software.amazon.awssdk/s3
shadow project(":bundler")
shadow 'software.amazon.awssdk:s3:2.34.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
test {
useJUnitPlatform()
}
configurations.implementation.extendsFrom(configurations.shadow)
shadowJar {
configurations = [project.configurations.shadow]
exclude("META-INF")
dependencies {
exclude(dependency("software.amazon.awssdk:aws-xml-protocol:.*"))
exclude(dependency("org.lz4:lz4-java:.*"))
exclude(dependency("it.unimi.dsi:fastutil:.*"))
exclude(dependency("io.netty:netty-all:.*"))
}
minimize()
//relocate 'com.google', 'sfcraft.relocation.google'
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": inputs.properties.version
}
}
jar {
// Minecraft 26.1+ is unobfuscated, so there is no remapJar step; the shaded
// jar is the distributable mod. Keep the thin jar under a separate classifier.
archiveClassifier = 'dev'
inputs.property "archivesName", project.base.archivesName
from("LICENSE") {
rename { "${it}_${inputs.properties.archivesName}" }
}
}
shadowJar {
archiveClassifier = ''
}
assemble.dependsOn shadowJar
// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}