Skip to content

Commit

Permalink
fix delete
Browse files Browse the repository at this point in the history
close session before removing files prevents issues with missing files which are written to or read from active sessions
  • Loading branch information
MutsiMutsi committed Aug 27, 2020
1 parent 1b895cc commit 8a2155b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions surge/nSurge.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ func Start(runtime *wails.Runtime, args []string) {
if args != nil && len(args) > 0 && len(args[0]) > 0 {
askUser("startDownloadMagnetLinks", "{files : ["+args[0]+"]}")
}

//Just paste one of your own magnets (from the startup logs) here to download something over nkn from yourself to test if no-one is online
//go ParsePayloadString("surge://|file|justatvshow.mp4|219091405|cd0731496277102a869dacb0e99b7708c2b708824b647ffeb267de4743b7856e|a536528d2e321623375535af88974d7a7899836f9b84644320023bc3af3b9cf1|/")
}
}

Expand Down Expand Up @@ -710,6 +713,15 @@ func OpenFileDialog() (string, error) {

//RemoveFile removes file from surge db and optionally from disk
func RemoveFile(Hash string, FromDisk bool) bool {

//Close sessions for this file
for _, session := range Sessions {
if session.FileHash == Hash {
closeSession(session)
break
}
}

fileWriteLock.Lock()

if FromDisk {
Expand Down Expand Up @@ -737,12 +749,6 @@ func RemoveFile(Hash string, FromDisk bool) bool {

go BuildSeedString()

/*for _, session := range Sessions {
if session.FileHash == Hash {
closeSession(session)
}
}*/

return true
}

Expand Down

0 comments on commit 8a2155b

Please sign in to comment.