feat: add services and separate further
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"log/slog"
|
||||
"orbits-server/internal/server/bootstrap"
|
||||
"orbits-server/internal/server/database"
|
||||
"orbits-server/internal/shared/utility"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -34,12 +33,12 @@ func applyFS(env bootstrap.Environment, db *gorm.DB, fsOrphans []string) {
|
||||
return
|
||||
}
|
||||
|
||||
database.CreateFile(db, &fileData)
|
||||
os.Rename(fp, fileData.FilePath)
|
||||
_ = database.CreateFile(db, &fileData)
|
||||
_ = os.Rename(fp, fileData.FilePath)
|
||||
}()
|
||||
|
||||
case "strict":
|
||||
utility.RemoveFile(fp)
|
||||
_ = os.Remove(fp)
|
||||
|
||||
case "dry":
|
||||
slog.Debug("dry mode", "file", fp)
|
||||
|
||||
@@ -33,13 +33,13 @@ func scanFS(env bootstrap.Environment) (map[string]struct{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res := make(map[string]struct{})
|
||||
resp := make(map[string]struct{})
|
||||
for _, f := range fsFiles {
|
||||
full := filepath.Join(env.ContentDirectory, f.Name())
|
||||
res[full] = struct{}{}
|
||||
resp[full] = struct{}{}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func scanDB(db *gorm.DB) (map[string]database.File, error) {
|
||||
@@ -48,10 +48,10 @@ func scanDB(db *gorm.DB) (map[string]database.File, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res := make(map[string]database.File)
|
||||
resp := make(map[string]database.File)
|
||||
for _, f := range files {
|
||||
res[f.FilePath] = f
|
||||
resp[f.FilePath] = f
|
||||
}
|
||||
|
||||
return res, nil
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user