added flag to enable image removal

This commit is contained in:
Philipp Häfelfinger 2019-03-24 23:58:35 +01:00
parent 5896670c87
commit 435af4b591
2 changed files with 15 additions and 6 deletions

View File

@ -7,4 +7,5 @@ noUpload = false # If set to true, the metadata gets prepared but the upload is
piwigoPassword = # This is password to the given username.
piwigoUrl = # The root url without tailing slash to your piwigo installation.
piwigoUser = # The username to use during sync.
removeImages = false # If set to true, images scheduled to delete will be removed from the piwigo server. Be sure you want to delete images before enabling this flag.
sqliteDb = ./localstate.db # The connection string to the sql lite database file.

View File

@ -19,6 +19,7 @@ var (
piwigoUrl = flag.String("piwigoUrl", "", "The root url without tailing slash to your piwigo installation.")
piwigoUser = flag.String("piwigoUser", "", "The username to use during sync.")
piwigoPassword = flag.String("piwigoPassword", "", "This is password to the given username.")
removeImages = flag.Bool("removeImages", false, "If set to true, images scheduled to delete will be removed from the piwigo server. Be sure you want to delete images before enabling this flag.")
)
func Run() {
@ -57,16 +58,23 @@ func Run() {
logErrorAndExit(err, 7)
}
if *noUpload {
logrus.Warnln("Skipping upload of images as flag noUpload is set to true!")
_ = context.piwigo.Logout()
os.Exit(90)
}
if !(*noUpload) {
err = uploadImages(context.piwigo, context.dataStore)
if err != nil {
logErrorAndExit(err, 8)
}
} else {
logrus.Warnln("Skipping upload of images as flag noUpload is set to true!")
}
if *removeImages {
err = deleteImages(context.piwigo, context.dataStore)
if err != nil {
logErrorAndExit(err, 9)
}
} else {
logrus.Info("The flag removeImages is disabled. Skipping...")
}
_ = context.piwigo.Logout()
}