Skip to content

Commit

Permalink
Add init_only flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilobyte22 committed Oct 25, 2020
1 parent c532931 commit 29a6985
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "PackUpdate"

version := "3.0"
version := "3.1-rc1"

scalaVersion := "2.12.8"

Expand All @@ -11,4 +11,4 @@ libraryDependencies += "net.sourceforge.argparse4j" % "argparse4j" % "0.8.1"
libraryDependencies += "org.json4s" % "json4s-jackson_2.12" % "3.6.7"
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.2.0"

Compile / mainClass := Some("at.chaosfield.packupdate.Main")
Compile / mainClass := Some("at.chaosfield.packupdate.Main")
10 changes: 8 additions & 2 deletions src/main/java/at/chaosfield/packupdate/common/ComponentFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public enum ComponentFlag {
*
* It is undefined behaviour to set both this option and no_integrity (current implementation will ignore this option
* in that case)
*
* Will be ignored if init_only is set.
*/
// TODO: handle properly when upgrading from legacy
ForceOverwrite("force_overwrite"),

/**
Expand All @@ -56,7 +57,12 @@ public enum ComponentFlag {
* It is undefined behaviour to set both this option and force_overwrite (current implementation will ignore this option
* in that case)
*/
NoIntegrity("no_integrity")
NoIntegrity("no_integrity"),

/**
* Only initializes the files. It will neither overwrite any existing files nor delete any files after removing the component.
*/
InitOnly("init_only")

;

Expand Down
6 changes: 4 additions & 2 deletions src/main/scala/at/chaosfield/packupdate/common/Update.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object Update {
runDownload(component, file, ui)
ui.subStatusUpdate(Some("Extracting..."))
configDir.mkdirs()
val files = FileManager.extractZip(file, configDir, component.hasFlag(ComponentFlag.ForceOverwrite), ui)
val files = FileManager.extractZip(file, configDir, !component.hasFlag(ComponentFlag.InitOnly) && component.hasFlag(ComponentFlag.ForceOverwrite), ui)
file.deleteOnExit()
ui.subStatusUpdate(None)
files.map(f => InstalledFile(Util.absoluteToRelativePath(f._1, config.minecraftDir), f._2)).toArray
Expand Down Expand Up @@ -255,7 +255,9 @@ object Update {
} else {
newComponent.flags.contains(ComponentFlag.Disabled)
}
RemovedComponent(oldComponent).execute(config, ui)
if (!newComponent.flags.contains(ComponentFlag.InitOnly)) {
RemovedComponent(oldComponent).execute(config, ui)
}
NewComponent(newComponent).executeInternal(config, disabled, ui)
}
}
Expand Down

0 comments on commit 29a6985

Please sign in to comment.