瀏覽代碼

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

George Baugh 5 月之前
父節點
當前提交
9d5c57c549
共有 1 個文件被更改,包括 2 次插入 和 3 次删除
  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
         }