Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Stifler6996/apt-mirror.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Georgiev <chutz@gg3.net>2022-05-17 10:17:40 +0300
committerGitHub <noreply@github.com>2022-05-17 10:17:40 +0300
commit9c4e752f91f9287ad33fdfa1fa452fa5d5a22901 (patch)
tree6576bc0c28ac877958a183e953e61b0e422a9970
parentc672c6e3eaa6a91b1eb5e5c8e3c2c417df06ae9b (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-xapt-mirror11
1 files changed, 9 insertions, 2 deletions
diff --git a/apt-mirror b/apt-mirror
index 48d084c..03c4375 100755
--- a/apt-mirror
+++ b/apt-mirror
@@ -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");
}