Code cleanup

This commit is contained in:
Borna Rajković committed 2024-01-06 14:17:22 +01:00
1 parent 20cc4db097
commit f5cdbe1bd3
6 files changed
+27 -19

No files matched your search

+4 -5
View File
@@ -2,7 +2,6 @@ package resource
import (
"context"
"io/ioutil"
"log"
"os"
"path/filepath"
@@ -46,9 +45,9 @@ func checkFileExists(path string) bool {
_, err := os.Stat(path)
return err == nil
}
func (f *fileManager) Download(ctx context.Context, path string) (file []byte, err error) {
func (f *fileManager) Download(_ context.Context, path string) (file []byte, err error) {
fullPath := filepath.Join(f.path, path)
file, err = ioutil.ReadFile(fullPath)
file, err = os.ReadFile(fullPath)
if err != nil {
log.Println("Manager | failed downloading (" + path + ") cause: " + err.Error())
}
@@ -99,11 +98,11 @@ func copyFolder(source, destination string, overwrite bool) error {
doesExist = true
}
if !doesExist || overwrite {
var data, err1 = ioutil.ReadFile(filepath.Join(source, relPath))
var data, err1 = os.ReadFile(filepath.Join(source, relPath))
if err1 != nil {
return err1
}
return ioutil.WriteFile(filepath.Join(destination, relPath), data, 0777)
return os.WriteFile(filepath.Join(destination, relPath), data, 0777)
} else {
return nil
}
+7 -7
View File
@@ -66,22 +66,22 @@ func (a *awsManager) Upload(request UploadRequest) {
a.addToCurrentlyUploading(request.Path)
a.requests <- request
}
func (a *awsManager) Presign(ctx context.Context, path string) (string, error) {
func (a *awsManager) Presign(_ context.Context, path string) (string, error) {
if !a.waitForUploadComplete(path) {
return "", errors.New("failed upload")
}
// ask cache for latest url
if url, err := a.cache.Get(path); err == nil {
return url, nil
if uri, err := a.cache.Get(path); err == nil {
return uri, nil
}
// if there is no value in cache, presign url and add it to cache
url, err := a.presign(path, a.expiration)
uri, err := a.presign(path, a.expiration)
if err != nil {
a.cache.Set(path, url, a.expiration)
_ = a.cache.Set(path, uri, a.expiration)
}
return url, err
return uri, err
}
func (a *awsManager) Download(ctx context.Context, path string) (file []byte, err error) {
func (a *awsManager) Download(_ context.Context, path string) (file []byte, err error) {
return a.download(path)
}
func (a *awsManager) Copy(from string, to string, overwrite bool) error {