From ee67788d592102d8bb0675d2c5b9a8696049b00d Mon Sep 17 00:00:00 2001 From: nemunaire Date: Fri, 26 Feb 2016 01:31:00 +0100 Subject: [PATCH] Expect full downloadable file pathname (allow CDN) --- admin/fill_exercices.sh | 3 ++- backend/main.go | 2 -- libfic/team_my.go | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/admin/fill_exercices.sh b/admin/fill_exercices.sh index 91248456..9d66f680 100755 --- a/admin/fill_exercices.sh +++ b/admin/fill_exercices.sh @@ -2,6 +2,7 @@ BASEURL="http://localhost:8081" BASEURI="https://srs.epita.fr/owncloud/remote.php/webdav/FIC 2016" +BASEFILE="/files" CLOUDPASS=fic:'f>t\nV33R|(+?$i*' new_theme() { @@ -29,7 +30,7 @@ new_file() { EXERCICE="$2" URI="$3" - curl -f -s -d "{\"URI\": \"$URI\"}" "${BASEURL}/api/themes/$THEME/$EXERCICE/files" | + curl -f -s -d "{\"URI\": \"${BASEFILE}${URI}\"}" "${BASEURL}/api/themes/$THEME/$EXERCICE/files" | grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+" } diff --git a/backend/main.go b/backend/main.go index b7a3c8a6..02936718 100644 --- a/backend/main.go +++ b/backend/main.go @@ -17,7 +17,6 @@ import ( var TeamsDir string var SubmissionDir string -var BaseURL string func watchsubdir(watcher *inotify.Watcher, pathname string) error { log.Println("Watch new directory:", pathname) @@ -44,7 +43,6 @@ func watchsubdir(watcher *inotify.Watcher, pathname string) error { func main() { var dsn = flag.String("dsn", "fic:fic@/fic", "DSN to connect to the MySQL server") - flag.StringVar(&BaseURL, "baseurl", "http://fic.srs.epita.fr/", "URL prepended to each URL") flag.StringVar(&SubmissionDir, "submission", "./submissions", "Base directory where save submissions") flag.StringVar(&TeamsDir, "teams", "../TEAMS", "Base directory where save teams JSON files") flag.Parse() diff --git a/libfic/team_my.go b/libfic/team_my.go index 58355495..046bfe20 100644 --- a/libfic/team_my.go +++ b/libfic/team_my.go @@ -3,7 +3,6 @@ package fic import ( "encoding/hex" "fmt" - "path" "time" ) @@ -87,7 +86,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) { return nil, err } else { for _, f := range files { - exercice.Files = append(exercice.Files, myTeamFile{path.Join("/files", f.Path), f.Name, hex.EncodeToString(f.Checksum), f.Size}) + exercice.Files = append(exercice.Files, myTeamFile{f.Path, f.Name, hex.EncodeToString(f.Checksum), f.Size}) } }