Skip to content

Commit

Permalink
Bump version: 0.1.1 → 0.1.2
Browse files Browse the repository at this point in the history
fix: Directories were not being cleaned up when syncing
arzkar committed Oct 4, 2023
1 parent a9d4bc9 commit 2a71491
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .git-utils-bump.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.1
current_version = 0.1.2
commit = True
tag = False
tag_format = v{tag}
3 changes: 1 addition & 2 deletions cmd/pull.go
Original file line number Diff line number Diff line change
@@ -102,8 +102,7 @@ func pull(sourcePath string, destinationPath string, dryRun bool, checksum bool,
}

// Remove the destination file & its parent from the map if it exists
delete(destinationFileMap, destFile)
delete(destinationFileMap, filepath.Dir(destFile))
destinationFileMap = utils.DeleteAllParentDirectories(destinationFileMap, destFile)
}

// Remove any remaining files in the destination directory that were not in the source
5 changes: 2 additions & 3 deletions cmd/push.go
Original file line number Diff line number Diff line change
@@ -93,16 +93,15 @@ func push(sourcePath string, destinationPath string, dryRun bool, checksum bool,
fmt.Printf("Skipped: %s -> %s (File already exists and is up to date)\n\n", color.RedString(file), color.RedString(sanitizedDestFile))
}
// Remove the destination file & its parent from the map if it exists
delete(destinationFileMap, destFile)
delete(destinationFileMap, filepath.Dir(destFile))
destinationFileMap = utils.DeleteAllParentDirectories(destinationFileMap, destFile)
}

// Remove any remaining files in the destination directory that were not in the source
for destFile := range destinationFileMap {
sanitizedDestFile := utils.SanitizeAndroidPath(destFile)
fmt.Printf("Removing: %s\n", color.YellowString(sanitizedDestFile))
if !dryRun {
output, err := exec.Command("adb", "shell", "rm", fmt.Sprintf(`"%s"`, sanitizedDestFile)).CombinedOutput()
output, err := exec.Command("adb", "shell", "rm -r", fmt.Sprintf(`"%s"`, sanitizedDestFile)).CombinedOutput()
if err != nil {
errorMessage := strings.TrimSpace(string(output))
fmt.Printf("Failed to remove file: %s\nError: %s\n", color.RedString(sanitizedDestFile), color.RedString(errorMessage))
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ import (
var rootCmd = &cobra.Command{
Use: "adb-sync",
Short: "A CLI to sync between android & local system using adb",
Long: `adb-sync v0.1.1
Long: `adb-sync v0.1.2
Copyright (c) Arbaaz Laskar <[email protected]>
A CLI to sync between android & local system using adb
11 changes: 11 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
@@ -283,3 +283,14 @@ func parseAdbLsOutput(output string) []string {

return filePaths
}

// Remove the destination file & its parent from the map if it exists
func DeleteAllParentDirectories(destinationFileMap map[string]bool, path string) map[string]bool {
for path != "\\" { // Stop when you reach the root directory
delete(destinationFileMap, path)
// Move to the parent directory
path = filepath.Dir(path)
}

return destinationFileMap
}

0 comments on commit 2a71491

Please sign in to comment.