From 3d27bebcc9f0917923adcecd730d4e046c841276 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 2 Jun 2020 16:32:09 +0100 Subject: Proper full fix for local queue handling (hopefully) --- local.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'local.go') diff --git a/local.go b/local.go index 26c2ba8..e112eed 100644 --- a/local.go +++ b/local.go @@ -178,9 +178,19 @@ func (a *LocalConn) DelFromQueue(url string, handle string) error { s := string(b) i := strings.Index(s, handle) + if i == -1 { + return fmt.Errorf("Warning: %s not found in queue %s, so not deleted", handle, url) + } // store the joining of part before and part after handle - complete := s[0:i] + s[i + len(handle) + 2:len(s)] + var complete string + // the '+2' is 1 for newline character + 1 to move beyond handle + if len(s) >= len(handle) + 2 { + if i > 0 { + complete = s[0:i] + } + complete += s[i + len(handle) + 2:len(s)] + } f, err := os.Create(filepath.Join(a.TempDir, url)) if err != nil { -- cgit v1.2.1-24-ge1ad