@@ -675,7 +675,11 @@ cache_artifacts() {
675
675
cache_cwd_directory " .venv" " python virtualenv"
676
676
cache_cwd_directory " .build" " swift build"
677
677
cache_cwd_directory " .netlify/plugins" " build plugins"
678
- cache_cwd_directory " target" " rust compile output"
678
+
679
+ if [ -f Cargo.toml ] || [ -f Cargo.lock ]
680
+ then
681
+ cache_cwd_directory_fast_copy " target" " rust compile output"
682
+ fi
679
683
680
684
cache_home_directory " .yarn_cache" " yarn cache"
681
685
cache_home_directory " .cache/pip" " pip cache"
@@ -686,8 +690,12 @@ cache_artifacts() {
686
690
cache_home_directory " .composer" " composer dependencies"
687
691
cache_home_directory " .homebrew-cache" , " homebrew cache"
688
692
cache_home_directory " .rustup" " rust rustup cache"
689
- cache_home_directory " .cargo/registry" " rust cargo registry cache"
690
- cache_home_directory " .cargo/bin" " rust cargo bin cache"
693
+
694
+ if [ -f Cargo.toml ] || [ -f Cargo.lock ]
695
+ then
696
+ cache_home_directory " .cargo/registry" " rust cargo registry cache"
697
+ cache_home_directory " .cargo/bin" " rust cargo bin cache"
698
+ fi
691
699
692
700
# Don't follow the Go import path or we'll store
693
701
# the origin repo twice.
@@ -748,6 +756,17 @@ move_cache() {
748
756
fi
749
757
}
750
758
759
+ fast_copy_cache () {
760
+ local src=$1
761
+ local dst=$2
762
+ if [ -d $src ]
763
+ then
764
+ echo " Started $3 "
765
+ cp --reflink=always $src $dst
766
+ echo " Finished $3 "
767
+ fi
768
+ }
769
+
751
770
restore_home_cache () {
752
771
move_cache " $NETLIFY_CACHE_DIR /$1 " " $HOME /$1 " " restoring cached $2 "
753
772
}
@@ -764,6 +783,10 @@ cache_cwd_directory() {
764
783
move_cache " $PWD /$1 " " $NETLIFY_CACHE_DIR /$1 " " saving $2 "
765
784
}
766
785
786
+ cache_cwd_directory_fast_copy () {
787
+ fast_copy_cache " $PWD /$1 " " $NETLIFY_CACHE_DIR /$1 " " saving $2 "
788
+ }
789
+
767
790
install_missing_commands () {
768
791
if [[ $BUILD_COMMAND_PARSER == * " grunt" * ]]
769
792
then
0 commit comments