summaryrefslogtreecommitdiff
path: root/local.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-06-02 16:32:09 +0100
committerNick White <git@njw.name>2020-06-02 16:32:09 +0100
commit3d27bebcc9f0917923adcecd730d4e046c841276 (patch)
tree0253cd4562b1f7d0804107c76eea4739beedf71a /local.go
parentdab03345abce18b4cfde479f2be67a07d05b77e9 (diff)
Proper full fix for local queue handling (hopefully)
Diffstat (limited to 'local.go')
-rw-r--r--local.go12
1 files changed, 11 insertions, 1 deletions
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 {