admin: new argument --rapidimport to speed up the import but don't ensure consistency
This commit is contained in:
parent
5c377f63de
commit
fa7e0e25c4
@ -19,6 +19,7 @@ import (
|
|||||||
var CloudDAVBase string
|
var CloudDAVBase string
|
||||||
var CloudUsername string
|
var CloudUsername string
|
||||||
var CloudPassword string
|
var CloudPassword string
|
||||||
|
var RapidImport bool
|
||||||
|
|
||||||
type uploadedFile struct {
|
type uploadedFile struct {
|
||||||
URI string
|
URI string
|
||||||
@ -77,6 +78,13 @@ func createExerciceFile(exercice fic.Exercice, body []byte) (interface{}, error)
|
|||||||
|
|
||||||
pathname := path.Join(fic.FilesDir, strings.ToLower(base32.StdEncoding.EncodeToString(hash[:])), path.Base(fromURI))
|
pathname := path.Join(fic.FilesDir, strings.ToLower(base32.StdEncoding.EncodeToString(hash[:])), path.Base(fromURI))
|
||||||
|
|
||||||
|
// Remove the file if it exists
|
||||||
|
if _, err := os.Stat(pathname); os.IsExist(err) && !RapidImport {
|
||||||
|
if err := os.Remove(pathname); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(pathname); os.IsNotExist(err) {
|
if _, err := os.Stat(pathname); os.IsNotExist(err) {
|
||||||
log.Println(logStr, pathname)
|
log.Println(logStr, pathname)
|
||||||
if err := os.MkdirAll(path.Dir(pathname), 0777); err != nil {
|
if err := os.MkdirAll(path.Dir(pathname), 0777); err != nil {
|
||||||
|
@ -30,6 +30,7 @@ func main() {
|
|||||||
"Base directory where found challenges files, cloud part")
|
"Base directory where found challenges files, cloud part")
|
||||||
flag.StringVar(&api.CloudUsername, "clouduser", "fic", "Username used to sync")
|
flag.StringVar(&api.CloudUsername, "clouduser", "fic", "Username used to sync")
|
||||||
flag.StringVar(&api.CloudPassword, "cloudpass", "", "Password used to sync")
|
flag.StringVar(&api.CloudPassword, "cloudpass", "", "Password used to sync")
|
||||||
|
flag.BoolVar(&api.RapidImport, "rapidimport", false, "Don't try to reimport an existing file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
log.SetPrefix("[admin] ")
|
log.SetPrefix("[admin] ")
|
||||||
|
Loading…
Reference in New Issue
Block a user