implemented various things

This commit is contained in:
2023-02-28 19:05:09 +01:00
parent 2a42cbb07a
commit 8e5f33c99b
12 changed files with 297 additions and 114 deletions

View File

@@ -19,6 +19,7 @@ package api
import (
"archive/zip"
"errors"
"io"
"os"
"path/filepath"
@@ -26,15 +27,12 @@ import (
)
// cleanup an upload directory, either because we got an error in the
// middle of an upload or something else went wrong. we fork off a go
// routine because this may block.
// middle of an upload or something else went wrong.
func cleanup(dir string) {
go func() {
err := os.RemoveAll(dir)
if err != nil {
Log("Failed to remove dir %s: %s", dir, err.Error())
}
}()
err := os.RemoveAll(dir)
if err != nil {
Log("Failed to remove dir %s: %s", dir, err.Error())
}
}
func ZipSource(source, target string) error {
@@ -60,7 +58,10 @@ func ZipSource(source, target string) error {
newDir, err := os.Getwd()
if err != nil {
}
//Log("Current Working Direcotry: %s\n, source: %s", newDir, source)
if newDir != source {
err = errors.New("Failed to changedir!")
return
}
err = filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
// 2. Go through all the files of the source