admin: Implement sychronization backends
We are now able, depending on configuration, to retrieve files from either WebDAV or local file system.
This commit is contained in:
parent
6237f7755a
commit
8f7de926d3
7 changed files with 281 additions and 160 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/api"
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
"srs.epita.fr/fic-server/settings"
|
||||
)
|
||||
|
@ -63,13 +64,13 @@ func StripPrefix(prefix string, h http.Handler) http.Handler {
|
|||
func main() {
|
||||
// Read paremeters from environment
|
||||
if v, exists := os.LookupEnv("FICCLOUD_URL"); exists {
|
||||
api.CloudDAVBase = v
|
||||
sync.CloudDAVBase = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FICCLOUD_USER"); exists {
|
||||
api.CloudUsername = v
|
||||
sync.CloudUsername = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FICCLOUD_PASS"); exists {
|
||||
api.CloudPassword = v
|
||||
sync.CloudPassword = v
|
||||
}
|
||||
|
||||
// Read parameters from command line
|
||||
|
@ -81,11 +82,10 @@ func main() {
|
|||
flag.StringVar(&api.TeamsDir, "teams", "./TEAMS", "Base directory where save teams JSON files")
|
||||
flag.StringVar(&settings.SettingsDir, "settings", settings.SettingsDir, "Base directory where load and save settings")
|
||||
flag.StringVar(&fic.FilesDir, "files", fic.FilesDir, "Base directory where found challenges files, local part")
|
||||
flag.StringVar(&api.CloudDAVBase, "clouddav", api.CloudDAVBase,
|
||||
flag.StringVar(&sync.CloudDAVBase, "clouddav", sync.CloudDAVBase,
|
||||
"Base directory where found challenges files, cloud part")
|
||||
flag.StringVar(&api.CloudUsername, "clouduser", api.CloudUsername, "Username used to sync")
|
||||
flag.StringVar(&api.CloudPassword, "cloudpass", api.CloudPassword, "Password used to sync")
|
||||
flag.BoolVar(&api.RapidImport, "rapidimport", api.RapidImport, "Don't try to reimport an existing file")
|
||||
flag.StringVar(&sync.CloudUsername, "clouduser", sync.CloudUsername, "Username used to sync")
|
||||
flag.StringVar(&sync.CloudPassword, "cloudpass", sync.CloudPassword, "Password used to sync")
|
||||
flag.BoolVar(&fic.OptionalDigest, "optionaldigest", fic.OptionalDigest, "Is the digest required when importing files?")
|
||||
flag.BoolVar(&fic.StrongDigest, "strongdigest", fic.StrongDigest, "Are BLAKE2b digests required instead of SHA-1 or BLAKE2b?")
|
||||
flag.Parse()
|
||||
|
|
Reference in a new issue