Skip to content

Commit 7f6f538

Browse files
committed
Merge branch 'v0.3.1-beta' into development
2 parents 90c3b50 + 60cd010 commit 7f6f538

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

surge/FileListSorting.go

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package surge
22

3+
import "strings"
4+
35
/*type Interface interface {
46
// Len is the number of elements in the collection.
57
Len() int
@@ -24,15 +26,19 @@ func (a sortBySeederCountDesc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
2426

2527
type sortByFileNameAsc []FileListing
2628

27-
func (a sortByFileNameAsc) Len() int { return len(a) }
28-
func (a sortByFileNameAsc) Less(i, j int) bool { return a[i].FileName < a[j].FileName }
29-
func (a sortByFileNameAsc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
29+
func (a sortByFileNameAsc) Len() int { return len(a) }
30+
func (a sortByFileNameAsc) Less(i, j int) bool {
31+
return strings.ToLower(a[i].FileName) < strings.ToLower(a[j].FileName)
32+
}
33+
func (a sortByFileNameAsc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
3034

3135
type sortByFileNameDesc []FileListing
3236

33-
func (a sortByFileNameDesc) Len() int { return len(a) }
34-
func (a sortByFileNameDesc) Less(i, j int) bool { return a[i].FileName > a[j].FileName }
35-
func (a sortByFileNameDesc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
37+
func (a sortByFileNameDesc) Len() int { return len(a) }
38+
func (a sortByFileNameDesc) Less(i, j int) bool {
39+
return strings.ToLower(a[i].FileName) > strings.ToLower(a[j].FileName)
40+
}
41+
func (a sortByFileNameDesc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
3642

3743
type sortByFileSizeAsc []FileListing
3844

@@ -48,12 +54,16 @@ func (a sortByFileSizeDesc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
4854

4955
type sortLocalByFileNameAsc []File
5056

51-
func (a sortLocalByFileNameAsc) Len() int { return len(a) }
52-
func (a sortLocalByFileNameAsc) Less(i, j int) bool { return a[i].FileName < a[j].FileName }
53-
func (a sortLocalByFileNameAsc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
57+
func (a sortLocalByFileNameAsc) Len() int { return len(a) }
58+
func (a sortLocalByFileNameAsc) Less(i, j int) bool {
59+
return strings.ToLower(a[i].FileName) < strings.ToLower(a[j].FileName)
60+
}
61+
func (a sortLocalByFileNameAsc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
5462

5563
type sortLocalByFileNameDesc []File
5664

57-
func (a sortLocalByFileNameDesc) Len() int { return len(a) }
58-
func (a sortLocalByFileNameDesc) Less(i, j int) bool { return a[i].FileName > a[j].FileName }
59-
func (a sortLocalByFileNameDesc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
65+
func (a sortLocalByFileNameDesc) Len() int { return len(a) }
66+
func (a sortLocalByFileNameDesc) Less(i, j int) bool {
67+
return strings.ToLower(a[i].FileName) > strings.ToLower(a[j].FileName)
68+
}
69+
func (a sortLocalByFileNameDesc) Swap(i, j int) { a[i], a[j] = a[j], a[i] }

surge/download.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ func downloadChunks(file *File, randomChunks []int) {
141141
//Check if file is still tracked in surge
142142
if err != nil {
143143
log.Println("Download Job Terminated", "File no longer in DB")
144-
pushError("Download Job Terminated", "File no longer in DB")
145144
return
146145
}
147146

@@ -151,7 +150,6 @@ func downloadChunks(file *File, randomChunks []int) {
151150
dbFile, err = dbGetFile(file.FileHash)
152151
if err != nil {
153152
log.Println("Download Job Terminated", "File no longer in DB")
154-
pushError("Download Job Terminated", "File no longer in DB")
155153
return
156154
}
157155

surge/sessionmanager/session.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,7 @@ func closeSession(address string) {
234234
sessionLockMapLock.Lock()
235235
defer sessionLockMapLock.Unlock()
236236

237-
sessionLockMapLock.Lock()
238237
session, exists := sessionMap[address]
239-
sessionLockMapLock.Unlock()
240238

241239
//Close nkn session, nill out the pointers
242240
if exists {
@@ -249,9 +247,7 @@ func closeSession(address string) {
249247
session = nil
250248

251249
//Delete from the map
252-
sessionLockMapLock.Lock()
253250
delete(sessionMap, address)
254-
sessionLockMapLock.Unlock()
255251

256252
log.Println("Download Session closed for: ", address)
257253
fmt.Println(string("\033[31m"), "Download Session closed for: ", address, string("\033[0m"))

0 commit comments

Comments
 (0)