Skip to content

Commit 111d03c

Browse files
authored
Some Android devices create unparsable backups without -nocompress flag (#75)
I see we have duplicated ADB commands between the streaming and non-steaming modes. This is not ideal as we could introduce subtle differences or bugs
1 parent 831d5e2 commit 111d03c

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

acquisition/streaming_buffer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (sp *StreamingPuller) BackupToWriter(arg string, writer io.Writer) error {
162162
return fmt.Errorf("writer cannot be nil")
163163
}
164164

165-
args := []string{"exec-out", "bu", "backup", arg}
165+
args := []string{"exec-out", "bu", "backup", "-nocompress", arg}
166166
if sp.serial != "" {
167167
args = append([]string{"-s", sp.serial}, args...)
168168
}

adb/adb.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ func (a *ADB) Push(localPath, remotePath string) (string, error) {
159159
// Backup generates a backup of the specified app, or of all.
160160
func (a *ADB) Backup(arg string) error {
161161
cmd := exec.Command(a.ExePath, "backup", "-nocompress", arg)
162-
return cmd.Run()
162+
output, err := cmd.CombinedOutput()
163+
if err != nil {
164+
return fmt.Errorf("%w: %s", err, string(output))
165+
}
166+
return nil
163167
}
164168

165169
// Bugreport generates a bugreport of the the device

modules/backup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (b *Backup) Run(acq *acquisition.Acquisition, fast bool) error {
7575
// Traditional mode: create backup file and move to storage directory
7676
err = adb.Client.Backup(arg)
7777
if err != nil {
78-
log.Debugf("Impossible to get backup: %w", err)
78+
log.Debugf("Impossible to get backup: %v", err)
7979
return err
8080
}
8181

0 commit comments

Comments
 (0)