diff options
author | Georgi Georgiev <chutz@gg3.net> | 2022-05-17 10:17:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 10:17:40 +0300 |
commit | 9c4e752f91f9287ad33fdfa1fa452fa5d5a22901 (patch) | |
tree | 6576bc0c28ac877958a183e953e61b0e422a9970 | |
parent | c672c6e3eaa6a91b1eb5e5c8e3c2c417df06ae9b (diff) |
Hardlink if possible, after all, this is what the checksummed files are for (#22)
This can save significant space as it will link the checksummed files to
the actual files, which is the original intent of these files.
And if the link is not supported or fails - we fall back to the original
file copy.
-rwxr-xr-x | apt-mirror | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -885,12 +885,19 @@ sub copy_file { if ( compare( $from, $to ) != 0 ) { unlink($to); } } - unless ( copy( $from, $to ) ) + my @stat_from = stat($from); + if ( -f $to ) + { + my @stat_to = stat($to); + return if ("@stat_to" eq "@stat_from"); + } + + unless ( link( $from, $to ) or copy( $from, $to ) ) { warn("apt-mirror: can't copy $from to $to"); return; } - my ( $atime, $mtime ) = ( stat($from) )[ 8, 9 ]; + my ( $atime, $mtime ) = @stat_from[ 8, 9 ]; utime( $atime, $mtime, $to ) or die("apt-mirror: can't utime $to"); } |