diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-11-08 12:22:46 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-11-08 12:22:46 -0700 |
commit | 126eed1359b37a527e992300e8b8e539d357268b (patch) | |
tree | ddd9a8a5902415aeec905134c6a356e1f987074c /bin/ifuse-photos-to-tmp | |
parent | b857c30cfe6001e4e1d2d43a348fc1e6ff903a30 (diff) | |
download | dotfiles-126eed1359b37a527e992300e8b8e539d357268b.tar.gz |
attempt to improve ifuse-photos-to-tmp unmounting
Diffstat (limited to 'bin/ifuse-photos-to-tmp')
-rwxr-xr-x | bin/ifuse-photos-to-tmp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/bin/ifuse-photos-to-tmp b/bin/ifuse-photos-to-tmp index 45b46d24..7d631002 100755 --- a/bin/ifuse-photos-to-tmp +++ b/bin/ifuse-photos-to-tmp @@ -128,8 +128,8 @@ remove_tree(glob("$mount/PhotoData/Thumbnails/V2/DCIM/10*"), "$mount/PhotoData/MISC"); # (source: https://ubuntuforums.org/archive/index.php/t-2203298.html) -system "fusermount -u $mount"; -warn "failed to unmount $mount" unless ($? == 0); +say "attempting unmount of photos"; +patient_unmount($mount); system "ifuse --documents org.videolan.vlc-ios $mount"; die "could not mount $mount with ifuse" unless ($? == 0); @@ -150,11 +150,29 @@ foreach my $file (glob qq<"${mount}/Apple CoreAudio format*.caf">) { move $file, $target; } -system "fusermount -u $mount"; -warn "failed to unmount $mount" unless ($? == 0); +say "attempting unmount of voice notes"; +patient_unmount($mount); if (fork) { exit; } else { exec "xdg-open", $dest; } + +sub patient_unmount { + my $mount = shift; + my $count = 0; + while ($count < 3) { + system "fusermount -u $mount"; + if ($? == 0) { + say " unmounted."; + last; + } else { + print "\n" if $count > 0; + print "unmount failed; waiting a few seconds .."; + sleep 2; + $count++; + } + } + die "failed to unmount $mount" unless $? == 0; +} |