Ver Fonte

Fix #1: Don't copy files, but hardlink them

George Baugh há 5 meses atrás
pai
commit
9d5c57c549
1 ficheiros alterados com 2 adições e 3 exclusões
  1. 2 3
      lib/TPSGI.pm

+ 2 - 3
lib/TPSGI.pm

@@ -371,9 +371,8 @@ sub serve {
             if ( !-d $target_dir ) {
                 File::Path::make_path( $target_dir, { user => $<, group => $self->{gid}, chmod => 0755 } ) or die "Could not make dir $target_dir";
             }
-            File::Copy::copy( $path, $static_path ) or die "Could not copy $path to $static_path";
-            chown( $<, $self->{gid}, $static_path );
-            chmod( 0755, $static_path );
+            # hardlink to save disk space
+            link $path, $static_path;
 
             # TODO figure out cache invalidation, I guess check mtime/hash
         }