Skip to content

Commit d5ffdfb

Browse files
committed
Formatting
1 parent b94438a commit d5ffdfb

File tree

5 files changed

+45
-46
lines changed

5 files changed

+45
-46
lines changed

acquisition/acquisition.go

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,42 @@ import (
2525

2626
// Acquisition is the main object containing all phone information
2727
type Acquisition struct {
28-
UUID string `json:"uuid"`
29-
AndroidQFVersion string `json:"androidqf_version"`
30-
StoragePath string `json:"storage_path"`
31-
Started time.Time `json:"started"`
32-
Completed time.Time `json:"completed"`
33-
Collector *adb.Collector `json:"collector"`
34-
TmpDir string `json:"tmp_dir"`
35-
SdCard string `json:"sdcard"`
36-
Cpu string `json:"cpu"`
28+
UUID string `json:"uuid"`
29+
AndroidQFVersion string `json:"androidqf_version"`
30+
StoragePath string `json:"storage_path"`
31+
Started time.Time `json:"started"`
32+
Completed time.Time `json:"completed"`
33+
Collector *adb.Collector `json:"collector"`
34+
TmpDir string `json:"tmp_dir"`
35+
SdCard string `json:"sdcard"`
36+
Cpu string `json:"cpu"`
3737
}
3838

3939
// New returns a new Acquisition instance.
4040
func New(path string) (*Acquisition, error) {
4141
acq := Acquisition{
42-
UUID: uuid.New().String(),
43-
Started: time.Now().UTC(),
42+
UUID: uuid.New().String(),
43+
Started: time.Now().UTC(),
4444
AndroidQFVersion: utils.Version,
4545
}
4646

47-
if path == "" {
48-
acq.StoragePath = filepath.Join(rt.GetExecutableDirectory(), acq.UUID)
49-
} else {
50-
acq.StoragePath = path
51-
}
52-
// Check if the path exist
53-
stat, err := os.Stat(acq.StoragePath)
54-
if os.IsNotExist(err) {
55-
err := os.Mkdir(acq.StoragePath, 0o755)
56-
if err != nil {
57-
return nil, fmt.Errorf("failed to create acquisition folder: %v", err)
58-
}
59-
} else {
60-
if !stat.IsDir() {
61-
return nil, fmt.Errorf("path exist and is not a folder")
62-
}
63-
}
47+
if path == "" {
48+
acq.StoragePath = filepath.Join(rt.GetExecutableDirectory(), acq.UUID)
49+
} else {
50+
acq.StoragePath = path
51+
}
52+
// Check if the path exist
53+
stat, err := os.Stat(acq.StoragePath)
54+
if os.IsNotExist(err) {
55+
err := os.Mkdir(acq.StoragePath, 0o755)
56+
if err != nil {
57+
return nil, fmt.Errorf("failed to create acquisition folder: %v", err)
58+
}
59+
} else {
60+
if !stat.IsDir() {
61+
return nil, fmt.Errorf("path exist and is not a folder")
62+
}
63+
}
6464

6565
// Get system information first to get tmp folder
6666
err = acq.GetSystemInformation()
@@ -109,25 +109,25 @@ func (a *Acquisition) GetSystemInformation() error {
109109
return fmt.Errorf("failed to run `adb shell env`: %v", err)
110110
}
111111
a.TmpDir = "/data/local/tmp/"
112-
a.SdCard = "/sdcard/"
112+
a.SdCard = "/sdcard/"
113113
for _, line := range strings.Split(out, "\n") {
114114
line = strings.TrimSpace(line)
115115
if strings.HasPrefix(line, "TMPDIR=") {
116116
a.TmpDir = strings.TrimPrefix(line, "TMPDIR=")
117117
}
118-
if strings.HasPrefix(line, "EXTERNAL_STORAGE=") {
119-
a.SdCard = strings.TrimPrefix(line, "EXTERNAL_STORAGE=")
120-
}
121-
}
122-
if !strings.HasSuffix(a.TmpDir, "/") {
123-
a.TmpDir = a.TmpDir + "/"
124-
}
125-
if !strings.HasSuffix(a.SdCard, "/") {
126-
a.SdCard = a.SdCard + "/"
127-
}
118+
if strings.HasPrefix(line, "EXTERNAL_STORAGE=") {
119+
a.SdCard = strings.TrimPrefix(line, "EXTERNAL_STORAGE=")
120+
}
121+
}
122+
if !strings.HasSuffix(a.TmpDir, "/") {
123+
a.TmpDir = a.TmpDir + "/"
124+
}
125+
if !strings.HasSuffix(a.SdCard, "/") {
126+
a.SdCard = a.SdCard + "/"
127+
}
128128

129129
log.Debugf("Found temp folder at %s", a.TmpDir)
130-
log.Debugf("Found sdcard at %s", a.SdCard)
130+
log.Debugf("Found sdcard at %s", a.SdCard)
131131
return nil
132132
}
133133

assets/assets.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ package assets
77

88
import (
99
"embed"
10-
"os"
1110
"errors"
11+
"os"
1212
"path/filepath"
1313

1414
saveRuntime "github.com/botherder/go-savetime/runtime"
@@ -32,7 +32,7 @@ func DeployAssets() error {
3232
assetFile, err := os.OpenFile(assetPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o755)
3333
if err != nil {
3434
// Asset file already exists. Do not try overwriting
35-
if (errors.Is(err, os.ErrExist)) {
35+
if errors.Is(err, os.ErrExist) {
3636
continue
3737
} else {
3838
return err

modules/bugreport.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func (b *Bugreport) InitStorage(storagePath string) error {
3232
}
3333

3434
func (b *Bugreport) Run(acq *acquisition.Acquisition, fast bool) error {
35-
3635
log.Info(
3736
"Generating a bugreport for the device...",
3837
)

modules/files.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ func (f *Files) Run(acq *acquisition.Acquisition, fast bool) error {
5858
if acq.TmpDir != "/data/local/tmp/" {
5959
folders = append(folders, acq.TmpDir)
6060
}
61-
if acq.SdCard != "/sdcard/" {
61+
if acq.SdCard != "/sdcard/" {
6262
folders = append(folders, acq.SdCard)
63-
}
63+
}
6464

6565
for _, folder := range folders {
6666
var out []adb.FileInfo

utils/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package utils
22

33
// Store the build verion information; set by linker flag
4-
var Version string
4+
var Version string

0 commit comments

Comments
 (0)