Skip to content

Commit

Permalink
Merge pull request #53 from marcelGoerentz/development
Browse files Browse the repository at this point in the history
Fix issue where 0 bytes has been read
  • Loading branch information
marcelGoerentz authored Jan 1, 2025
2 parents 192980a + 73725b3 commit 6b7e2fe
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 33 deletions.
3 changes: 3 additions & 0 deletions src/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func HandleByteOutput(stdOut io.ReadCloser, stream *Stream, errorChan chan Error
init = false
}
n, err := reader.Read(buffer)
if n == 0 {
continue
}
if err == io.EOF {
f.Close()
ShowDebug("Buffer reached EOF!", 3)
Expand Down
2 changes: 1 addition & 1 deletion src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func Init() (err error) {
// Menü für das Webinterface
System.WEB.Menu = []string{"playlist", "xmltv", "filter", "mapping", "users", "settings", "log", "logout"}

ShowInfo(fmt.Sprintf("Info:For help run: " + getPlatformFile(os.Args[0]) + " -h"))
ShowInfo(fmt.Sprintf("Info:For help run: %s %s", getPlatformFile(os.Args[0]), " -h"))

// Überprüfen ob Threadfin als root läuft
if os.Geteuid() == 0 {
Expand Down
6 changes: 1 addition & 5 deletions src/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,11 +878,7 @@ func buildDatabaseDVR() (err error) {
if value, ok := s[key]; ok {
if len(value) > 0 {

if _, ok := tmpGroupsM3U[value]; ok {
tmpGroupsM3U[value]++
} else {
tmpGroupsM3U[value] = 1
}
tmpGroupsM3U[value]++

groupTitle++
}
Expand Down
17 changes: 8 additions & 9 deletions src/internal/up2date/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (

// ClientInfo : Information about the key (NAME OS, ARCH, UUID, KEY)
type ClientInfo struct {
Arch string `json:"arch,required"`
Branch string `json:"branch,required"`
Arch string `json:"arch"`
Branch string `json:"branch"`
CMD string `json:"cmd,omitempty"`
Name string `json:"name,required"`
OS string `json:"os,required"`
URL string `json:"url,required"`
Name string `json:"name"`
OS string `json:"os"`
URL string `json:"url"`

Response ServerResponse `json:"response,omitempty"`
}
Expand Down Expand Up @@ -82,7 +82,7 @@ func serverRequest() (err error) {
}

// Check redirect 301 <---> 308
redirect, err := http.NewRequest("POST", Updater.URL, nil)
redirect, _ := http.NewRequest("POST", Updater.URL, nil)

client := &http.Client{}
client.CheckRedirect = func(redirect *http.Request, via []*http.Request) error {
Expand All @@ -101,7 +101,7 @@ func serverRequest() (err error) {
}
// ---

req, err := http.NewRequest("POST", Updater.URL, bytes.NewBuffer(jsonByte))
req, _ := http.NewRequest("POST", Updater.URL, bytes.NewBuffer(jsonByte))
req.Header.Set("Content-Type", "application/json")

client = &http.Client{}
Expand All @@ -113,8 +113,7 @@ func serverRequest() (err error) {

if resp.StatusCode != http.StatusOK {
//fmt.Println(resp.StatusCode, Updater.URL, Updater.CMD)
err = fmt.Errorf(fmt.Sprintf("%d: %s (%s)", resp.StatusCode, http.StatusText(resp.StatusCode), Updater.URL))
return err
return fmt.Errorf("%d: %s (%s)", resp.StatusCode, http.StatusText(resp.StatusCode), Updater.URL)
}

Updater.CMD = ""
Expand Down
13 changes: 2 additions & 11 deletions src/internal/up2date/client/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func DoUpdate(fileType, filenameBIN string) (err error) {
}

// Change binary filename to .filename
binary, err := os.Executable()
binary, _ := os.Executable()
var filename = getFilenameFromPath(binary)
var path = getPlatformPath(binary)
var oldBinary = path + "_old_" + filename
Expand Down Expand Up @@ -110,7 +110,7 @@ func DoUpdate(fileType, filenameBIN string) (err error) {
}

// Set the permission
err = os.Chmod(binary, 0755)
os.Chmod(binary, 0755)

// Close the new file !Windows
out.Close()
Expand Down Expand Up @@ -184,15 +184,6 @@ func restorOldBinary(oldBinary, newBinary string) {
os.Rename(oldBinary, newBinary)
}

func getPlatformFile(filename string) string {

path, file := filepath.Split(filename)
var newPath = filepath.Dir(path)
var newFileName = newPath + string(os.PathSeparator) + file

return newFileName
}

func getFilenameFromPath(path string) string {

file := filepath.Base(path)
Expand Down
2 changes: 1 addition & 1 deletion src/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func getErrMsg(errCode int) (errMsg string) {

// Tuner
case 2105:
errMsg = fmt.Sprintf("The number of tuners has changed, you have to delete " + System.Name + " in Plex / Emby HDHR and set it up again.")
errMsg = fmt.Sprintf("The number of tuners has changed, you have to delete %s in Plex / Emby HDHR and set it up again.", System.Name)
case 2106:
errMsg = "This function is only available with XEPG as EPG source"

Expand Down
7 changes: 1 addition & 6 deletions src/xepg.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ func buildXEPG(background bool) {

System.ScanInProgress = 1

var err error

Data.Cache.Images = imgcache.NewImageCache(Settings.CacheImages, System.Folder.ImagesCache, System.BaseURL)
if err != nil {
ShowError(err, 0)
}

if Settings.EpgSource == "XEPG" {

Expand Down Expand Up @@ -728,7 +723,7 @@ func mapping() (err error) {

} else {

ShowError(fmt.Errorf(fmt.Sprintf("Missing EPG data: %s", xepgChannel.Name)), 0)
ShowError(fmt.Errorf("missing EPG data: %s", xepgChannel.Name), 0)
ShowWarning(2302)
// xepgChannel.XActive = false

Expand Down

0 comments on commit 6b7e2fe

Please sign in to comment.