~ubuntu-branches/debian/sid/stella/sid

« back to all changes in this revision

Viewing changes to src/tools/prune_snapshots.pl

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2013-06-28 09:53:13 UTC
  • mfrom: (1.3.6)
  • Revision ID: package-import@ubuntu.com-20130628095313-j8jkkgxpvx1t18ym
Tags: 3.9-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
open(INFILE, "$ARGV[0]");
17
17
foreach $line (<INFILE>)
18
18
{
19
 
        if($line =~ /\|/)
20
 
        {
21
 
                chomp $line;
22
 
                ($md5, $name, $other) = split (/\|/, $line);
23
 
                $key = $name . ".png";
24
 
                $builtin{$key} = $key;
25
 
        }
 
19
  if($line =~ /\|/)
 
20
  {
 
21
    chomp $line;
 
22
    ($md5, $name, $other) = split (/\|/, $line);
 
23
    $key = $name . ".png";
 
24
    $builtin{$key} = $key;
 
25
  }
26
26
}
27
27
close(INFILE);
28
28
 
33
33
close(SNAPDIR);
34
34
foreach $file (@files)
35
35
{
36
 
        ($base,$path,$type) = fileparse($file);
37
 
        $directory{$base} = $base;
 
36
  ($base,$path,$type) = fileparse($file);
 
37
  $directory{$base} = $base;
38
38
}
39
39
 
40
40
# All files in %builtin but not in %directory are 'missing' snapshots
41
41
while(($key, $value) = each(%builtin))
42
42
{
43
 
        if(!defined $directory{$key})
44
 
        {
45
 
                push(@missing, $key);
46
 
        }
 
43
  if(!defined $directory{$key})
 
44
  {
 
45
    push(@missing, $key);
 
46
  }
47
47
}
48
48
 
49
49
# All files in %directory but not in %builtin are redundant, and should be deleted
50
50
while(($key, $value) = each(%directory))
51
51
{
52
 
        if(!defined $builtin{$key})
53
 
        {
54
 
                $file = $ARGV[1] . "/" . $key;
55
 
                push(@delete, $file);
56
 
        }
 
52
  if(!defined $builtin{$key})
 
53
  {
 
54
    $file = $ARGV[1] . "/" . $key;
 
55
    push(@delete, $file);
 
56
  }
57
57
}
58
58
 
59
59
$size = @missing;
60
60
print "Missing snapshots: ($size)\n\n";
61
61
if($size > 0)
62
62
{
63
 
        @missing = sort(@missing);
64
 
        foreach $file (@missing)
65
 
        {
66
 
                print "$file\n";
67
 
        }
 
63
  @missing = sort(@missing);
 
64
  foreach $file (@missing)
 
65
  {
 
66
    print "$file\n";
 
67
  }
68
68
}
69
69
 
70
70
$size = @delete;
71
71
print "\n\nExtra snapshots: ($size)\n\n";
72
72
if($size > 0)
73
73
{
74
 
        @delete = sort(@delete);
75
 
        foreach $file (@delete)
76
 
        {
77
 
                print "$file\n";
78
 
        }
 
74
  @delete = sort(@delete);
 
75
  foreach $file (@delete)
 
76
  {
 
77
    print "$file\n";
 
78
  }
79
79
 
80
 
        print "\nDelete extra snapshots [yN]: ";
81
 
        chomp ($input = <STDIN>);
82
 
        if($input eq 'y')
83
 
        { 
84
 
                foreach $file (@delete)
85
 
                {
86
 
                        $cmd = "rm \"$file\"";
87
 
                        system($cmd);
88
 
                }
89
 
        }
 
80
  print "\nDelete extra snapshots [yN]: ";
 
81
  chomp ($input = <STDIN>);
 
82
  if($input eq 'y')
 
83
  { 
 
84
    foreach $file (@delete)
 
85
    {
 
86
      $cmd = "rm \"$file\"";
 
87
      system($cmd);
 
88
    }
 
89
  }
90
90
}
91
91
 
92
92
 
93
93
sub usage {
94
 
        print "prune_snapshots.pl [listrominfo data] [snapshot dir]\n";
95
 
        exit(0);
 
94
  print "prune_snapshots.pl [listrominfo data] [snapshot dir]\n";
 
95
  exit(0);
96
96
}