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
28
28
path = File .expand_path(candidate)
29
29
return path if File .exists?(path)
30
30
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 % }
36
44
end
37
45
38
46
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
71
71
File .delete(destination)
72
72
end
73
73
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
78
78
FileUtils .cp(source, destination)
79
- else
80
- raise ex
81
79
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 % }
83
91
end
84
92
end
85
93
end
Original file line number Diff line number Diff line change @@ -41,16 +41,25 @@ module Shards
41
41
end
42
42
43
43
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
48
48
return false
49
- else
50
- raise errno
51
49
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 % }
54
63
end
55
64
56
65
def available_versions
You can’t perform that action at this time.
0 commit comments