File tree Expand file tree Collapse file tree 3 files changed +45
-20
lines changed Expand file tree Collapse file tree 3 files changed +45
-20
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,19 @@ module Shards
2828 path = File .expand_path(candidate)
2929 return path if File .exists?(path)
3030
31- begin
32- Dir .mkdir_p(path)
33- return path
34- rescue Errno
35- end
31+ {% if compare_versions(Crystal ::VERSION , " 0.34.0-0" ) > 0 % }
32+ begin
33+ Dir .mkdir_p(path)
34+ return path
35+ rescue File ::Error
36+ end
37+ {% else % }
38+ begin
39+ Dir .mkdir_p(path)
40+ return path
41+ rescue Errno
42+ end
43+ {% end % }
3644 end
3745
3846 raise Error .new(" Failed to find or create cache directory" )
Original file line number Diff line number Diff line change @@ -71,15 +71,23 @@ module Shards
7171 File .delete(destination)
7272 end
7373
74- begin
75- File .link(source, destination)
76- rescue ex : Errno
77- if { Errno :: EPERM , Errno :: EXDEV }.includes?(ex.errno)
74+ { % if compare_versions( Crystal :: VERSION , " 0.34.0-0 " ) > 0 % }
75+ begin
76+ File .link(source, destination)
77+ rescue File :: Error
7878 FileUtils .cp(source, destination)
79- else
80- raise ex
8179 end
82- end
80+ {% else % }
81+ begin
82+ File .link(source, destination)
83+ rescue ex : Errno
84+ if {Errno ::EPERM , Errno ::EXDEV }.includes?(ex.errno)
85+ FileUtils .cp(source, destination)
86+ else
87+ raise ex
88+ end
89+ end
90+ {% end % }
8391 end
8492 end
8593 end
Original file line number Diff line number Diff line change @@ -41,16 +41,25 @@ module Shards
4141 end
4242
4343 private def check_install_path_target
44- begin
45- real_install_path = File .real_path(install_path)
46- rescue errno : Errno
47- if errno.errno == Errno :: ENOENT
44+ { % if compare_versions( Crystal :: VERSION , " 0.34.0-0 " ) > 0 % }
45+ begin
46+ real_install_path = File .real_path(install_path)
47+ rescue File :: NotFoundError
4848 return false
49- else
50- raise errno
5149 end
52- end
53- real_install_path == expanded_local_path
50+ real_install_path == expanded_local_path
51+ {% else % }
52+ begin
53+ real_install_path = File .real_path(install_path)
54+ rescue errno : Errno
55+ if errno.errno == Errno ::ENOENT
56+ return false
57+ else
58+ raise errno
59+ end
60+ end
61+ real_install_path == expanded_local_path
62+ {% end % }
5463 end
5564
5665 def available_versions
You can’t perform that action at this time.
0 commit comments