Ubuntu Pastebin

Paste from zyga at Tue, 4 Apr 2017 15:28:30 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
commit 360ecc800f461c50eb37d4d7a22469872dc8b0cc
Author: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Date:   Tue Apr 4 17:27:16 2017 +0200

    daemon: sort apps by name
    
    This patch makes per-snap app ordering deterministic (alphanumeric
    depending on app name).
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

diff --git a/daemon/snap.go b/daemon/snap.go
index 0c28837..5bd7c64 100644
--- a/daemon/snap.go
+++ b/daemon/snap.go
@@ -24,6 +24,7 @@ import (
 	"fmt"
 	"os"
 	"path/filepath"
+	"sort"
 	"time"
 
 	"github.com/snapcore/snapd/osutil"
@@ -178,8 +179,14 @@ func mapLocal(about aboutSnap) map[string]interface{} {
 		status = "active"
 	}
 
+	appNames := make([]string, 0, len(localSnap.Apps))
+	for appName := range localSnap.Apps {
+		appNames = append(appNames, appName)
+	}
+	sort.Strings(appNames)
 	apps := make([]appJSON, 0, len(localSnap.Apps))
-	for _, app := range localSnap.Apps {
+	for _, appName := range appNames {
+		app := localSnap.Apps[appName]
 		var installedDesktopFile string
 		if osutil.FileExists(app.DesktopFile()) {
 			installedDesktopFile = app.DesktopFile()
Download as text