func (ms MusicServer) create(port string, indexFolder, musicFolder, addressMask, webfolder string) { ms.folder = indexFolder ms.textIndexer = music.LoadTextIndexer(ms.folder) ms.albumManager = music.NewAlbumManager(ms.folder) ms.webfolder = "resources/" if musicFolder != "" { ms.musicFolder = musicFolder if addressMask != "" { for i, val := range strings.Split(addressMask, ".") { if intVal, e := strconv.ParseInt(val, 10, 32); e == nil { ms.addressMask[i] = int(intVal) } } } } if webfolder != "" { ms.webfolder = webfolder } ms.dico = music.LoadDictionnary(ms.folder) if port == "" { logger.GetLogger().Fatal("Impossible to run node, port is not defined") } localIP := ms.findExposedURL() mux := ms.createRoutes() logger.GetLogger().Info("Runner ok on :", localIP, port) http.ListenAndServe(":"+port, mux) logger.GetLogger().Error("Runner ko") }
// Redindex all data but keep all index in memories to increase treatment func (ms MusicServer) fullReindex(response http.ResponseWriter, request *http.Request) { if !ms.checkRequester(request) { return } if ms.musicFolder != "" { dico := music.LoadDictionnary(ms.folder) dico.FullReindex(ms.musicFolder) } }
// update local folder if exist func (ms *MusicServer) update(response http.ResponseWriter, request *http.Request) { // Always check addressMask. If no define, mask is 0.0.0.0 and nothing is accepted (except localhost) if !ms.checkRequester(request) { return } if ms.musicFolder != "" { dico := music.LoadDictionnary(ms.folder) ms.textIndexer = dico.Browse(ms.musicFolder) } }
func main() { args := arguments.ParseArgs() switch args["task"] { case "browse": dico := music.LoadDictionnary(args["workingFolder"]) dico.Browse(args["browse"]) case "index": music.IndexArtists(args["workingFolder"]) default: fmt.Println("No task define. Available tasks (-task) : browse (-workingFolder and -browse required), index (-workingFolder required)") } }