Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Te-k committed Jan 25, 2024
1 parent b94438a commit d5ffdfb
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 46 deletions.
80 changes: 40 additions & 40 deletions acquisition/acquisition.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,42 @@ import (

// Acquisition is the main object containing all phone information
type Acquisition struct {
UUID string `json:"uuid"`
AndroidQFVersion string `json:"androidqf_version"`
StoragePath string `json:"storage_path"`
Started time.Time `json:"started"`
Completed time.Time `json:"completed"`
Collector *adb.Collector `json:"collector"`
TmpDir string `json:"tmp_dir"`
SdCard string `json:"sdcard"`
Cpu string `json:"cpu"`
UUID string `json:"uuid"`
AndroidQFVersion string `json:"androidqf_version"`
StoragePath string `json:"storage_path"`
Started time.Time `json:"started"`
Completed time.Time `json:"completed"`
Collector *adb.Collector `json:"collector"`
TmpDir string `json:"tmp_dir"`
SdCard string `json:"sdcard"`
Cpu string `json:"cpu"`
}

// New returns a new Acquisition instance.
func New(path string) (*Acquisition, error) {
acq := Acquisition{
UUID: uuid.New().String(),
Started: time.Now().UTC(),
UUID: uuid.New().String(),
Started: time.Now().UTC(),
AndroidQFVersion: utils.Version,
}

if path == "" {
acq.StoragePath = filepath.Join(rt.GetExecutableDirectory(), acq.UUID)
} else {
acq.StoragePath = path
}
// Check if the path exist
stat, err := os.Stat(acq.StoragePath)
if os.IsNotExist(err) {
err := os.Mkdir(acq.StoragePath, 0o755)
if err != nil {
return nil, fmt.Errorf("failed to create acquisition folder: %v", err)
}
} else {
if !stat.IsDir() {
return nil, fmt.Errorf("path exist and is not a folder")
}
}
if path == "" {
acq.StoragePath = filepath.Join(rt.GetExecutableDirectory(), acq.UUID)
} else {
acq.StoragePath = path
}
// Check if the path exist
stat, err := os.Stat(acq.StoragePath)
if os.IsNotExist(err) {
err := os.Mkdir(acq.StoragePath, 0o755)
if err != nil {
return nil, fmt.Errorf("failed to create acquisition folder: %v", err)
}
} else {
if !stat.IsDir() {
return nil, fmt.Errorf("path exist and is not a folder")
}
}

// Get system information first to get tmp folder
err = acq.GetSystemInformation()
Expand Down Expand Up @@ -109,25 +109,25 @@ func (a *Acquisition) GetSystemInformation() error {
return fmt.Errorf("failed to run `adb shell env`: %v", err)
}
a.TmpDir = "/data/local/tmp/"
a.SdCard = "/sdcard/"
a.SdCard = "/sdcard/"
for _, line := range strings.Split(out, "\n") {
line = strings.TrimSpace(line)
if strings.HasPrefix(line, "TMPDIR=") {
a.TmpDir = strings.TrimPrefix(line, "TMPDIR=")
}
if strings.HasPrefix(line, "EXTERNAL_STORAGE=") {
a.SdCard = strings.TrimPrefix(line, "EXTERNAL_STORAGE=")
}
}
if !strings.HasSuffix(a.TmpDir, "/") {
a.TmpDir = a.TmpDir + "/"
}
if !strings.HasSuffix(a.SdCard, "/") {
a.SdCard = a.SdCard + "/"
}
if strings.HasPrefix(line, "EXTERNAL_STORAGE=") {
a.SdCard = strings.TrimPrefix(line, "EXTERNAL_STORAGE=")
}
}
if !strings.HasSuffix(a.TmpDir, "/") {
a.TmpDir = a.TmpDir + "/"
}
if !strings.HasSuffix(a.SdCard, "/") {
a.SdCard = a.SdCard + "/"
}

log.Debugf("Found temp folder at %s", a.TmpDir)
log.Debugf("Found sdcard at %s", a.SdCard)
log.Debugf("Found sdcard at %s", a.SdCard)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package assets

import (
"embed"
"os"
"errors"
"os"
"path/filepath"

saveRuntime "github.com/botherder/go-savetime/runtime"
Expand All @@ -32,7 +32,7 @@ func DeployAssets() error {
assetFile, err := os.OpenFile(assetPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o755)
if err != nil {
// Asset file already exists. Do not try overwriting
if (errors.Is(err, os.ErrExist)) {
if errors.Is(err, os.ErrExist) {
continue
} else {
return err
Expand Down
1 change: 0 additions & 1 deletion modules/bugreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func (b *Bugreport) InitStorage(storagePath string) error {
}

func (b *Bugreport) Run(acq *acquisition.Acquisition, fast bool) error {

log.Info(
"Generating a bugreport for the device...",
)
Expand Down
4 changes: 2 additions & 2 deletions modules/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func (f *Files) Run(acq *acquisition.Acquisition, fast bool) error {
if acq.TmpDir != "/data/local/tmp/" {
folders = append(folders, acq.TmpDir)
}
if acq.SdCard != "/sdcard/" {
if acq.SdCard != "/sdcard/" {
folders = append(folders, acq.SdCard)
}
}

for _, folder := range folders {
var out []adb.FileInfo
Expand Down
2 changes: 1 addition & 1 deletion utils/build.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils

// Store the build verion information; set by linker flag
var Version string
var Version string

0 comments on commit d5ffdfb

Please sign in to comment.