@@ -25,42 +25,42 @@ import (
25
25
26
26
// Acquisition is the main object containing all phone information
27
27
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"`
37
37
}
38
38
39
39
// New returns a new Acquisition instance.
40
40
func New (path string ) (* Acquisition , error ) {
41
41
acq := Acquisition {
42
- UUID : uuid .New ().String (),
43
- Started : time .Now ().UTC (),
42
+ UUID : uuid .New ().String (),
43
+ Started : time .Now ().UTC (),
44
44
AndroidQFVersion : utils .Version ,
45
45
}
46
46
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
+ }
64
64
65
65
// Get system information first to get tmp folder
66
66
err = acq .GetSystemInformation ()
@@ -109,25 +109,25 @@ func (a *Acquisition) GetSystemInformation() error {
109
109
return fmt .Errorf ("failed to run `adb shell env`: %v" , err )
110
110
}
111
111
a .TmpDir = "/data/local/tmp/"
112
- a .SdCard = "/sdcard/"
112
+ a .SdCard = "/sdcard/"
113
113
for _ , line := range strings .Split (out , "\n " ) {
114
114
line = strings .TrimSpace (line )
115
115
if strings .HasPrefix (line , "TMPDIR=" ) {
116
116
a .TmpDir = strings .TrimPrefix (line , "TMPDIR=" )
117
117
}
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
+ }
128
128
129
129
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 )
131
131
return nil
132
132
}
133
133
0 commit comments