Hi,
There is a bug in CleanUp.pl if an mp3 is stored on a case-insensitive
filesystem, such as VFAT, and the source and destination files differ only
in case.
In this case, CleanUp.pl incorrectly detects that the destination exists,
and prompts the user "Overwrite Destination?". Many users will assume (as
I did), that choosing yes is a safe option, as they know the destination
doesn't really exist. However, answering Y, causes CleanUp.pl to unlink
the destination, which is of course the same as the source file.
This patch to CleanUp.pl checks to see if the two files are actually one,
in what is hopefully a fairly foolproof way. If so, the source file is
moved to a different path (by adding a ~), and then the script continues
as normal.
Rob
--
01010010 01101111 01100010 01100101 01110010 01110100
01001000 01100001 01110010 01110100
Index: tools/CleanUp.pl
===================================================================
RCS file: /src/repository/obs/tools/CleanUp.pl,v
retrieving revision 1.17
diff -u -r1.17 CleanUp.pl
--- tools/CleanUp.pl 2001/09/16 02:11:53 1.17
+++ tools/CleanUp.pl 2001/10/01 09:15:38
@@ -111,7 +111,7 @@
my ($Id, $Name, $Url, $TrackNum, $Size,
$ArtistName, $AlbumName, $Len) = @_;
my ($NewUrl, $Volume, $regexp, $UrlPath, $NewUrlPath);
- my ($path, $cmd, $from_path, $to_path);
+ my ($path, $cmd, $from_path, $to_path, $temp_path);
return 1 if (defined $Len && $Len != 0 && $UpdateLengthFast);
@@ -226,25 +226,44 @@
$from_path = $LocalVolumes->{$Volume} . $UrlPath;
if (-e $path)
{
- my (@info, $line);
+ my (@info, @infodest, $line);
- @info = stat($path);
- print "Destination file ($path) already exists.\n";
- print "Destination size: $info[7]\n";
+ @infodest = stat($path);
@info = stat($from_path);
- print " Source size: $info[7]\n\n";
- print "Overwrite destination? [y/N]: ";
- $line = <>;
- chop($line);
- $line =~ tr/ \r\n//d;
- if ($line eq 'y' || $line eq 'Y')
- {
- unlink($path);
- }
- else
- {
- return 1;
- }
+
+ print "Destination file ($path) already exists.\n";
+ if(uc($path) eq uc($from_path) &&
+ $infodest[0] == $info[0] &&
+ $infodest[1] == $info[1] &&
+ $infodest[3] == 1 ){
+ print "But the new and old file have same device/inode\n";
+ print "So assuming filesystem is case-insensitive.\n";
+ $temp_path="$from_path~";
+ if (!rename($from_path, $temp_path))
+ {
+ print "Move file failed. (from $from_path to $temp_path)\n";
+ return 0;
+ }
+ $from_path=$temp_path;
+ }
+ else
+ {
+ print "Destination size: $info[7]\n";
+
+ print " Source size: $info[7]\n\n";
+ print "Overwrite destination? [y/N]: ";
+ $line = <>;
+ chop($line);
+ $line =~ tr/ \r\n//d;
+ if ($line eq 'y' || $line eq 'Y')
+ {
+ unlink($path);
+ }
+ else
+ {
+ return 1;
+ }
+ }
}
if (!CreatePath($path))