Skip to content

Commit 53ea5ed

Browse files
committed
Added --add-trash option.
With `-add-trash` option, it is now possible to extract also files marked as deleted. Such files contain "_DELETED" in their filename.
1 parent e1d9e30 commit 53ea5ed

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/ios_backup_extractor.pl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
use constant {
3131
APP_NAME => 'ios_backup_extractor',
32-
APP_VERSION => '1.2.1 (2024-03-21)',
32+
APP_VERSION => '1.2.2 (2024-03-30)',
3333
};
3434

3535
my $wanted_extensions = 'jpg|jpeg|heic|png|mov';
@@ -57,6 +57,7 @@
5757
'list|l', # list available device backups
5858
'format|f=s', # output subdirectory format
5959
'since|s=s', # since DATE
60+
'add-trash', # extract also files from deleted
6061
'verbose|v', # display more info and warnings
6162
'dry|d', # “dry run”: doesn't make any real changes to the filesystem
6263
'out|o=s', # output directory
@@ -97,6 +98,7 @@ sub printHelp
9798
- ‘flat’ no subdirectories
9899
-s, --since DATE Extract and copy only files created since DATE.
99100
DATE must be in format YYYY-MM-DD.
101+
--add-trash Extract also items marked as deleted.
100102
-d, --dry Dry run, don't copy any files.
101103
-v, --verbose Show more information while running.
102104
-h, --help Display help.
@@ -114,6 +116,9 @@ sub printHelp
114116
Version:
115117
${ \APP_VERSION }
116118
119+
Homepage:
120+
https://github.com/joz-k/ios_backup_extractor
121+
117122
HELP_END
118123
exit;
119124
}
@@ -420,7 +425,12 @@ sub extractMediaFiles
420425
next;
421426
}
422427

423-
my $filename = $+{filename} . q{.} . lc $+{extension};
428+
# add '_DELETED' flag to files marked as deleted
429+
my $deleted_flag = ($cmd_options{'add-trash'} && $g_deleted_files{$relative_path})
430+
? '_DELETED'
431+
: q{};
432+
433+
my $filename = $+{filename} . $deleted_flag . q{.} . lc $+{extension};
424434

425435
# find the file in the blob storage
426436
my $subdir = $file_id =~ s/^(\w\w).+$/$1/r
@@ -456,7 +466,8 @@ sub extractMediaFiles
456466
# find a suitable filename (or `undef` if duplicate)
457467
my $unique_filename = findUniqueFilename ($blob_file, $filename, $out_sub_dir);
458468

459-
if ($g_deleted_files{$relative_path})
469+
if ( not($cmd_options{'add-trash'})
470+
&& $g_deleted_files{$relative_path})
460471
{
461472
printf "%3d. ($subdir/$file_id) %-13s → <IN_TRASH>, Skipping...\n",
462473
$file_index, $filename;
@@ -897,7 +908,7 @@ ($file_modif_timepiece, $since_date_aref)
897908

898909
sub findUniqueFilename ($blob_file, $filename, $out_sub_dir)
899910
{
900-
# check if the filename is unique. If there is a file with a same name,
911+
# check if the filename is unique. If there is a file with the same name,
901912
# check if it is a duplicate. If not, find a new unique name for this file.
902913

903914
# file doesn't exist, return the same filename

0 commit comments

Comments
 (0)