11package packaging
22
33import (
4- "crypto/rand"
54 "crypto/sha1"
65 "encoding/hex"
76 "fmt"
@@ -14,6 +13,7 @@ import (
1413 "strings"
1514
1615 ico "github.com/Kodeworks/golang-image-ico"
16+ "github.com/google/uuid"
1717
1818 "github.com/go-flutter-desktop/hover/internal/log"
1919)
@@ -102,14 +102,11 @@ var WindowsMsiTask = &packagingTask{
102102 },
103103 },
104104 generateInitFiles : func (packageName , path string ) {
105- b := make ([]byte , 16 )
106- _ , err := rand .Read (b )
107- if err != nil {
108- log .Errorf ("Failed to generate GUID: %v" , err )
109- os .Exit (1 )
110- }
111- upgradeCode := strings .ToUpper (fmt .Sprintf ("%x-%x-%x-%x-%x" , b [0 :4 ], b [4 :6 ], b [6 :8 ], b [8 :10 ], b [10 :]))
112- err = ioutil .WriteFile (filepath .Join (path , "upgrade-code.txt" ), []byte (fmt .Sprintf ("%s\n # This GUID is your upgrade code and ensures that you can properly update your app.\n # Don't change it." , upgradeCode )), 0755 )
105+ err := ioutil .WriteFile (
106+ filepath .Join (path , "upgrade-code.txt" ),
107+ []byte (fmt .Sprintf ("%s\n # This GUID is your upgrade code and ensures that you can properly update your app.\n # Don't change it." , uuid .New ())),
108+ 0755 ,
109+ )
113110 if err != nil {
114111 log .Errorf ("Failed to create `upgrade-code.txt` file: %v" , err )
115112 os .Exit (1 )
@@ -165,7 +162,7 @@ var WindowsMsiTask = &packagingTask{
165162 directoriesFileContent = append (directoriesFileContent , "<Include>" )
166163 directoryRefsFileContent = append (directoryRefsFileContent , "<Include>" )
167164 componentRefsFileContent = append (componentRefsFileContent , "<Include>" )
168- windowsMsiProcessFiles (filepath .Join (tmpPath , "build" , "flutter_assets" ))
165+ windowsMsiProcessFiles (filepath .Join (tmpPath , "build" ))
169166 directoriesFileContent = append (directoriesFileContent , "</Include>" )
170167 directoryRefsFileContent = append (directoryRefsFileContent , "</Include>" )
171168 componentRefsFileContent = append (componentRefsFileContent , "</Include>" )
@@ -216,11 +213,11 @@ func windowsMsiProcessFiles(path string) {
216213
217214 for _ , f := range files {
218215 p := filepath .Join (path , f .Name ())
219- relativePath := strings .Split (strings .Split (p , "flutter_assets " + pathSeparator )[1 ], pathSeparator )
216+ relativePath := strings .Split (strings .Split (p , "build " + pathSeparator )[1 ], pathSeparator )
220217 id := hashSha1 (strings .Join (relativePath , "" ))
221218 if f .IsDir () {
222219 directoriesFileContent = append (directoriesFileContent ,
223- fmt .Sprintf (`<Directory Id="FLUTTERASSETSDIRECTORY_ %s" Name="%s">` , id , f .Name ()),
220+ fmt .Sprintf (`<Directory Id="APPLICATIONROOTDIRECTORY_ %s" Name="%s">` , id , f .Name ()),
224221 )
225222 windowsMsiProcessFiles (p )
226223 directoriesFileContent = append (directoriesFileContent ,
@@ -229,22 +226,22 @@ func windowsMsiProcessFiles(path string) {
229226 } else {
230227 if len (relativePath ) > 1 {
231228 directoryRefsFileContent = append (directoryRefsFileContent ,
232- fmt .Sprintf (`<DirectoryRef Id="FLUTTERASSETSDIRECTORY_ %s">` , hashSha1 (strings .Join (relativePath [:len (relativePath )- 1 ], "" ))),
229+ fmt .Sprintf (`<DirectoryRef Id="APPLICATIONROOTDIRECTORY_ %s">` , hashSha1 (strings .Join (relativePath [:len (relativePath )- 1 ], "" ))),
233230 )
234231 } else {
235232 directoryRefsFileContent = append (directoryRefsFileContent ,
236- `<DirectoryRef Id="FLUTTERASSETSDIRECTORY ">` ,
233+ `<DirectoryRef Id="APPLICATIONROOTDIRECTORY ">` ,
237234 )
238235 }
239- fileSource := filepath .Join ("build" , "flutter_assets" , strings .Join (relativePath , pathSeparator ))
236+ fileSource := filepath .Join ("build" , strings .Join (relativePath , pathSeparator ))
240237 directoryRefsFileContent = append (directoryRefsFileContent ,
241- fmt .Sprintf (`<Component Id="flutter_assets_ %s" Guid="* ">` , id ),
242- fmt .Sprintf (`<File Id="flutter_assets_ %s" Source="%s" KeyPath="yes"/>` , id , fileSource ),
238+ fmt .Sprintf (`<Component Id="build_ %s" Guid="%s ">` , id , uuid . New () ),
239+ fmt .Sprintf (`<File Id="build_ %s" Source="%s" KeyPath="yes"/>` , id , fileSource ),
243240 "</Component>" ,
244241 "</DirectoryRef>" ,
245242 )
246243 componentRefsFileContent = append (componentRefsFileContent ,
247- fmt .Sprintf (`<ComponentRef Id="flutter_assets_ %s"/>` , id ),
244+ fmt .Sprintf (`<ComponentRef Id="build_ %s"/>` , id ),
248245 )
249246 }
250247 }
0 commit comments