added flag to enable image removal
This commit is contained in:
parent
5896670c87
commit
435af4b591
@ -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.
|
piwigoPassword = # This is password to the given username.
|
||||||
piwigoUrl = # The root url without tailing slash to your piwigo installation.
|
piwigoUrl = # The root url without tailing slash to your piwigo installation.
|
||||||
piwigoUser = # The username to use during sync.
|
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.
|
sqliteDb = ./localstate.db # The connection string to the sql lite database file.
|
||||||
|
@ -19,6 +19,7 @@ var (
|
|||||||
piwigoUrl = flag.String("piwigoUrl", "", "The root url without tailing slash to your piwigo installation.")
|
piwigoUrl = flag.String("piwigoUrl", "", "The root url without tailing slash to your piwigo installation.")
|
||||||
piwigoUser = flag.String("piwigoUser", "", "The username to use during sync.")
|
piwigoUser = flag.String("piwigoUser", "", "The username to use during sync.")
|
||||||
piwigoPassword = flag.String("piwigoPassword", "", "This is password to the given username.")
|
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() {
|
func Run() {
|
||||||
@ -57,15 +58,22 @@ func Run() {
|
|||||||
logErrorAndExit(err, 7)
|
logErrorAndExit(err, 7)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *noUpload {
|
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!")
|
logrus.Warnln("Skipping upload of images as flag noUpload is set to true!")
|
||||||
_ = context.piwigo.Logout()
|
|
||||||
os.Exit(90)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = uploadImages(context.piwigo, context.dataStore)
|
if *removeImages {
|
||||||
if err != nil {
|
err = deleteImages(context.piwigo, context.dataStore)
|
||||||
logErrorAndExit(err, 8)
|
if err != nil {
|
||||||
|
logErrorAndExit(err, 9)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logrus.Info("The flag removeImages is disabled. Skipping...")
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = context.piwigo.Logout()
|
_ = context.piwigo.Logout()
|
||||||
|
Loading…
Reference in New Issue
Block a user