@@ -34,43 +34,43 @@ import (
34
34
func (release * DownloadResource ) Install (downloadDir , tempPath , destDir * paths.Path ) error {
35
35
// Check the integrity of the package
36
36
if ok , err := release .TestLocalArchiveIntegrity (downloadDir ); err != nil {
37
- return fmt .Errorf (tr ("testing local archive integrity: %s" ) , err )
37
+ return fmt .Errorf (tr ("testing local archive integrity: %s" , err ) )
38
38
} else if ! ok {
39
39
return fmt .Errorf (tr ("checking local archive integrity" ))
40
40
}
41
41
42
42
// Create a temporary dir to extract package
43
43
if err := tempPath .MkdirAll (); err != nil {
44
- return fmt .Errorf (tr ("creating temp dir for extraction: %s" ) , err )
44
+ return fmt .Errorf (tr ("creating temp dir for extraction: %s" , err ) )
45
45
}
46
46
tempDir , err := tempPath .MkTempDir ("package-" )
47
47
if err != nil {
48
- return fmt .Errorf (tr ("creating temp dir for extraction: %s" ) , err )
48
+ return fmt .Errorf (tr ("creating temp dir for extraction: %s" , err ) )
49
49
}
50
50
defer tempDir .RemoveAll ()
51
51
52
52
// Obtain the archive path and open it
53
53
archivePath , err := release .ArchivePath (downloadDir )
54
54
if err != nil {
55
- return fmt .Errorf (tr ("getting archive path: %s" ) , err )
55
+ return fmt .Errorf (tr ("getting archive path: %s" , err ) )
56
56
}
57
57
file , err := os .Open (archivePath .String ())
58
58
if err != nil {
59
- return fmt .Errorf (tr ("opening archive file: %s" ) , err )
59
+ return fmt .Errorf (tr ("opening archive file: %s" , err ) )
60
60
}
61
61
defer file .Close ()
62
62
63
63
// Extract into temp directory
64
64
ctx , cancel := cleanup .InterruptableContext (context .Background ())
65
65
defer cancel ()
66
66
if err := extract .Archive (ctx , file , tempDir .String (), nil ); err != nil {
67
- return fmt .Errorf (tr ("extracting archive: %s" ) , err )
67
+ return fmt .Errorf (tr ("extracting archive: %s" , err ) )
68
68
}
69
69
70
70
// Check package content and find package root dir
71
71
root , err := findPackageRoot (tempDir )
72
72
if err != nil {
73
- return fmt .Errorf (tr ("searching package root dir: %s" ) , err )
73
+ return fmt .Errorf (tr ("searching package root dir: %s" , err ) )
74
74
}
75
75
76
76
// Ensure container dir exists
@@ -91,7 +91,7 @@ func (release *DownloadResource) Install(downloadDir, tempPath, destDir *paths.P
91
91
92
92
// Move/rename the extracted root directory in the destination directory
93
93
if err := root .Rename (destDir ); err != nil {
94
- return fmt .Errorf (tr ("moving extracted archive to destination dir: %s" ) , err )
94
+ return fmt .Errorf (tr ("moving extracted archive to destination dir: %s" , err ) )
95
95
}
96
96
97
97
// TODO
@@ -115,7 +115,7 @@ func IsDirEmpty(path *paths.Path) (bool, error) {
115
115
func findPackageRoot (parent * paths.Path ) (* paths.Path , error ) {
116
116
files , err := parent .ReadDir ()
117
117
if err != nil {
118
- return nil , fmt .Errorf (tr ("reading package root dir: %s" ) , err )
118
+ return nil , fmt .Errorf (tr ("reading package root dir: %s" , err ) )
119
119
}
120
120
var root * paths.Path
121
121
for _ , file := range files {
@@ -125,7 +125,7 @@ func findPackageRoot(parent *paths.Path) (*paths.Path, error) {
125
125
if root == nil {
126
126
root = file
127
127
} else {
128
- return nil , fmt .Errorf (tr ("no unique root dir in archive, found '%[1]s' and '%[2]s'" ) , root , file )
128
+ return nil , fmt .Errorf (tr ("no unique root dir in archive, found '%[1]s' and '%[2]s'" , root , file ) )
129
129
}
130
130
}
131
131
if root == nil {
0 commit comments