avoid temporary filenames with more than 255 characters.
This commit is contained in:
parent
fe23839aaf
commit
259d97bc99
|
@ -606,10 +606,16 @@ sub linkdup {
|
||||||
$st->gid == $self->name2gid($f->{g}) &&
|
$st->gid == $self->name2gid($f->{g}) &&
|
||||||
($st->mode & 07777) == $self->acl2mode($f)
|
($st->mode & 07777) == $self->acl2mode($f)
|
||||||
) {
|
) {
|
||||||
rename($backup_filename, "$backup_filename.$$.simba_backup") or die "cannot save $backup_filename to $backup_filename.$$.simba_backup: $!";
|
my ($dirname, $basename) = $backup_filename =~ m{(.*)/(.*)};
|
||||||
|
my $tmpname = "$basename.$$.simba_backup";
|
||||||
|
if (length($tmpname) > 255) {
|
||||||
|
$tmpname = substr($basename, 0, 235) . ".$$.simba_backup";
|
||||||
|
}
|
||||||
|
$tmpname = "$dirname/$tmpname";
|
||||||
|
rename($backup_filename, "$tmpname") or die "cannot save $backup_filename to $tmpname: $!";
|
||||||
if (link($oldfile, $backup_filename)) {
|
if (link($oldfile, $backup_filename)) {
|
||||||
$self->log(10, "linked (dup)");
|
$self->log(10, "linked (dup)");
|
||||||
unlink("$backup_filename.$$.simba_backup") or die "cannot unlink $backup_filename.$$.simba_backup: $!";
|
unlink("$tmpname") or die "cannot unlink $tmpname: $!";
|
||||||
$sth->finish();
|
$sth->finish();
|
||||||
my $t1 = gettimeofday();
|
my $t1 = gettimeofday();
|
||||||
$self->{counts}{dup2}++;
|
$self->{counts}{dup2}++;
|
||||||
|
@ -617,7 +623,7 @@ sub linkdup {
|
||||||
return $oldfile;
|
return $oldfile;
|
||||||
} else {
|
} else {
|
||||||
$self->log(5, "cannot link $oldfile to $backup_filename");
|
$self->log(5, "cannot link $oldfile to $backup_filename");
|
||||||
rename("$backup_filename.$$.simba_backup", $backup_filename) or die "cannot restore $backup_filename from $backup_filename.$$.simba_backup: $!";
|
rename("$tmpname", $backup_filename) or die "cannot restore $backup_filename from $tmpname: $!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue