File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"io"
6
6
"log"
7
+ "math/rand"
7
8
"path/filepath"
9
+ "strconv"
8
10
9
11
"github.com/spf13/cobra"
10
12
toast "gopkg.in/toast.v1"
@@ -42,17 +44,20 @@ func main() {
42
44
return
43
45
}
44
46
47
+ // only use 100 random file names to avoid too much garbage since this application closes before the windows executable completes
48
+ random := strconv .Itoa (rand .Intn (100 ) + 1 )
49
+
45
50
if len (icon ) > 0 && (icon [:7 ] == "http://" || icon [:8 ] == "https://" ) {
46
51
tmpFolder := os .TempDir ()
47
52
48
- err := DownloadFile (icon , filepath .Join (tmpFolder , "wsl-notify-send-icon-tmp.png" ))
53
+ err := DownloadFile (icon , filepath .Join (tmpFolder , "wsl-notify-send-icon-tmp" + random + " .png" ))
49
54
if err != nil {
50
55
log .Fatalln (err )
51
56
icon = ""
52
57
} else {
53
58
// had to comment this out because the toast wasn't getting invoked before the file was removed
54
- // defer os.Remove("wsl-notify-send-icon-tmp.png")
55
- icon = filepath .Join (tmpFolder , "wsl-notify-send-icon-tmp.png" )
59
+ // defer os.Remove("wsl-notify-send-icon-tmp"+random+" .png")
60
+ icon = filepath .Join (tmpFolder , "wsl-notify-send-icon-tmp" + random + " .png" )
56
61
}
57
62
}
58
63
You can’t perform that action at this time.
0 commit comments