Start refactoring
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"log"
|
||||
"mime/multipart"
|
||||
"opensavecloudserver/config"
|
||||
database2 "opensavecloudserver/data/internal/database"
|
||||
"opensavecloudserver/database"
|
||||
"os"
|
||||
"path"
|
||||
@@ -108,7 +109,7 @@ func CheckUploadToken(uploadToken string) (int, bool) {
|
||||
return -1, false
|
||||
}
|
||||
|
||||
func UploadToCache(file multipart.File, game *database.Game) error {
|
||||
func UploadToCache(file multipart.File, game *database2.Game) error {
|
||||
filePath := path.Join(config.Path().Cache, strconv.Itoa(game.UserId))
|
||||
if _, err := os.Stat(filePath); err != nil {
|
||||
err = os.Mkdir(filePath, 0766)
|
||||
@@ -133,7 +134,7 @@ func UploadToCache(file multipart.File, game *database.Game) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateAndMove(game *database.Game, hash string) error {
|
||||
func ValidateAndMove(game *database2.Game, hash string) error {
|
||||
filePath := path.Join(config.Path().Cache, strconv.Itoa(game.UserId), game.PathStorage)
|
||||
if err := checkHash(filePath, hash); err != nil {
|
||||
return err
|
||||
@@ -155,7 +156,7 @@ func checkHash(path, hash string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func moveToStorage(cachePath string, game *database.Game) error {
|
||||
func moveToStorage(cachePath string, game *database2.Game) error {
|
||||
filePath := path.Join(config.Path().Storage, strconv.Itoa(game.UserId))
|
||||
if _, err := os.Stat(filePath); err != nil {
|
||||
err = os.Mkdir(filePath, 0766)
|
||||
@@ -200,7 +201,7 @@ func RemoveFolders(userId int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func RemoveGame(userId int, game *database.Game) error {
|
||||
func RemoveGame(userId int, game *database2.Game) error {
|
||||
filePath := path.Join(config.Path().Storage, strconv.Itoa(userId), game.PathStorage)
|
||||
return os.Remove(filePath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user