Replaced the gin framwwork with echo
This commit is contained in:
@@ -260,15 +260,30 @@ func checkBrokenSongs() {
|
||||
}
|
||||
db.RemoveBrokenSongs(brokenSongs)
|
||||
}
|
||||
func SyncGamesNewFull() Response {
|
||||
return syncGamesNew(true)
|
||||
}
|
||||
|
||||
func SyncGamesNew() Response {
|
||||
func SyncGamesNewOnlyChanges() Response {
|
||||
return syncGamesNew(false)
|
||||
}
|
||||
|
||||
func syncGamesNew(full bool) Response {
|
||||
musicPath := os.Getenv("MUSIC_PATH")
|
||||
fmt.Printf("dir: %s\n", musicPath)
|
||||
repo = repository.New(db.Dbpool)
|
||||
start := time.Now()
|
||||
fmt.Printf("dir: %s\n", Conf.Path)
|
||||
foldersToSkip := []string{".sync", "dist", "old"}
|
||||
fmt.Println(foldersToSkip)
|
||||
|
||||
var err error
|
||||
gamesAdded = nil
|
||||
gamesReAdded = nil
|
||||
gamesChangedTitle = nil
|
||||
gamesChangedContent = nil
|
||||
gamesRemoved = nil
|
||||
catchedErrors = nil
|
||||
brokenSongs = nil
|
||||
|
||||
gamesBeforeSync, err = repo.FindAllGames(db.Ctx)
|
||||
handleError("FindAllGames Before", err, "")
|
||||
@@ -279,7 +294,7 @@ func SyncGamesNew() Response {
|
||||
err = repo.SetGameDeletionDate(db.Ctx)
|
||||
handleError("SetGameDeletionDate", err, "")
|
||||
|
||||
directories, err := os.ReadDir(Conf.Path)
|
||||
directories, err := os.ReadDir(musicPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -288,7 +303,7 @@ func SyncGamesNew() Response {
|
||||
for _, dir := range directories {
|
||||
go func() {
|
||||
defer syncWg.Done()
|
||||
syncGameNew(dir, foldersToSkip, Conf.Path)
|
||||
syncGameNew(dir, foldersToSkip, musicPath, full)
|
||||
}()
|
||||
}
|
||||
syncWg.Wait()
|
||||
@@ -339,7 +354,7 @@ func SyncGamesNew() Response {
|
||||
|
||||
for _, game := range gamesRemovedTemp {
|
||||
var found bool = false
|
||||
for key, _ := range gamesChangedTitle {
|
||||
for key := range gamesChangedTitle {
|
||||
if game == key {
|
||||
found = true
|
||||
//fmt.Printf("Game: %s, Found: %v break2\n", game, found)
|
||||
@@ -408,7 +423,7 @@ func checkBrokenSongNew(song repository.Song) {
|
||||
}
|
||||
}
|
||||
|
||||
func syncGameNew(file os.DirEntry, foldersToSkip []string, baseDir string) {
|
||||
func syncGameNew(file os.DirEntry, foldersToSkip []string, baseDir string, full bool) {
|
||||
if file.IsDir() && !contains(foldersToSkip, file.Name()) {
|
||||
gameDir := baseDir + file.Name() + "/"
|
||||
|
||||
@@ -441,6 +456,9 @@ func syncGameNew(file os.DirEntry, foldersToSkip []string, baseDir string) {
|
||||
}
|
||||
}
|
||||
|
||||
if full {
|
||||
status = TitleChanged
|
||||
}
|
||||
entries, err := os.ReadDir(gameDir)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user