Skip to content

Commit dc6ddf6

Browse files
authored
Merge pull request #22 from LIM-AeroCloud/rel/0.2.0
Rel/0.2.0
2 parents 49c3291 + 1eb3f9a commit dc6ddf6

File tree

14 files changed

+155
-131
lines changed

14 files changed

+155
-131
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
arch:
3232
- x64
3333
steps:
34-
- uses: actions/checkout@v4
34+
- uses: actions/checkout@v5
3535
- uses: julia-actions/setup-julia@v2
3636
with:
3737
version: ${{ matrix.version }}
@@ -53,7 +53,7 @@ jobs:
5353
contents: write
5454
statuses: write
5555
steps:
56-
- uses: actions/checkout@v4
56+
- uses: actions/checkout@v5
5757
- uses: julia-actions/setup-julia@v2
5858
with:
5959
version: '1'

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44
The format of the release notes follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6+
## [v0.2.0] - 2025-08-22
7+
8+
### Changed
9+
10+
- Added Enum `ErrorCode` for revised error handling with updated error codes ([#21])
11+
- Invalid paths give an `Base.IOError` during instatiation of an `SFTP.Client`
12+
- `pwd(::SFTP.Client)`: no validity checks of uri path. This should be done during instantiation
13+
of the `SFTP.Client` ([#22])
14+
15+
### Removed
16+
17+
- `pwd(::URI)`, `splitdir(uri::URI, path::AbstractString=".")`, and
18+
`basename(uri::URI, path::AbstractString=".")`: only methods with `SFTP.Client` allowed
19+
to avoid type piracy ([#22])
20+
21+
### Fixed
22+
23+
- Link targets are displayed as absolute paths again. This bug was introduced after switching
24+
internally from split to URIs.splitpath, which does not consider root folders ([#18]).
25+
626
## [v0.1.2] - 2025-05-31
727

828
### Deprecated
@@ -109,8 +129,12 @@ All changes for this released are documented in respect to this version.
109129
[v0.1.0]: https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.0
110130
[v0.1.1]: https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.1
111131
[v0.1.2]: https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.2
132+
[v0.2.0]: https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.2.0
112133
[#8]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/8
113134
[#9]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/9
114135
[#10]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/10
115136
[#13]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/13
116137
[#14]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/14
138+
[#18]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/18
139+
[#21]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/21
140+
[#22]: https://github.com/LIM-AeroCloud/SFTP.jl/issues/22

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SFTP"
22
uuid = "f44f501d-421f-4286-bfa3-132bd4e9b35e"
33
authors = ["Peter Bräuer <pb866.git@gmail.com>"]
4-
version = "0.1.2"
4+
version = "0.2.0"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ makedocs(
2323
"Home" => "index.md",
2424
"Server" => "server.md",
2525
"Filesystem" => "filesystem.md",
26+
"Error handling" => "error.md",
2627
"Troubleshooting" => "troubleshooting.md",
2728
"Release notes" => "release-notes.md",
2829
"Index" => "register.md"

docs/src/error.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Error handling
2+
3+
__SFTP.jl__ handles multiple errors related to server access and file structure on the remote
4+
system. Error codes are defined by the [`ErrorCode`](@ref SFTP.ErrorCode) enum and used as
5+
error code in `Base.IOError`.
6+
7+
```@docs
8+
SFTP.ErrorCode
9+
```

docs/src/filesystem.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ for more details on the `URI` struct.
1717

1818
## Navigating server paths
1919

20-
!!! warning "Deprecation warning"
21-
The [`pwd`](@ref) method for `URI` structs will be deprecated in v0.2.0 and
22-
replaced by and internal `cwd` method to avoid type piracy.
23-
2420
```@docs
2521
pwd
2622
cd(::SFTP.Client, ::AbstractString)
@@ -34,10 +30,6 @@ walkdir(::SFTP.Client, ::AbstractString; kwargs...)
3430

3531
## Analyse and manipulate server paths
3632

37-
!!! warning "Deprecation warning"
38-
All methods using `URI` instead of [`SFTP.Client`](@ref) in [`basename`](@ref)
39-
and [`splitdir`](@ref) will be deprecated in v0.2.0 to avoid type piracy.
40-
4133
!!! warning "Known issue"
4234
[URIs'](https://github.com/JuliaWeb/URIs.jl.git) `joinpath` method currently
4335
assigns two leading slashes (`//`) instead of one, if an absolute path is assigned

docs/src/release-notes.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@ EditURL = "https://github.com/LIM-AeroCloud/SFTP.jl/blob/master/CHANGELOG.md"
77
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88
The format of the release notes follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
99

10+
## [v0.2.0](https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.2.0) - 2025-08-22
11+
12+
### Changed
13+
14+
- Added Enum `ErrorCode` for revised error handling with updated error codes ([#21](https://github.com/LIM-AeroCloud/SFTP.jl/issues/21))
15+
- Invalid paths give an `Base.IOError` during instatiation of an `SFTP.Client`
16+
- `pwd(::SFTP.Client)`: no validity checks of uri path. This should be done during instantiation
17+
of the `SFTP.Client` ([#22](https://github.com/LIM-AeroCloud/SFTP.jl/issues/22))
18+
19+
### Removed
20+
21+
- `pwd(::URI)`, `splitdir(uri::URI, path::AbstractString=".")`, and
22+
`basename(uri::URI, path::AbstractString=".")`: only methods with `SFTP.Client` allowed
23+
to avoid type piracy ([#22](https://github.com/LIM-AeroCloud/SFTP.jl/issues/22))
24+
25+
### Fixed
26+
27+
- Link targets are displayed as absolute paths again. This bug was introduced after switching
28+
internally from split to URIs.splitpath, which does not consider root folders ([#18](https://github.com/LIM-AeroCloud/SFTP.jl/issues/18)).
29+
1030
## [v0.1.2](https://github.com/LIM-AeroCloud/SFTP.jl/releases/tag/v0.1.2) - 2025-05-31
1131

1232
### Deprecated

src/SFTP.jl

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
module SFTP
22

3+
# Error Codes for Error Handling of IO Errors
4+
"""
5+
# Enum `ErrorCode`
6+
7+
Error codes for SFTP connection and remote filesystem errors:
8+
9+
EC_INSTANTIATION_ERROR = -1
10+
EC_NOERROR = 0
11+
EC_ACCESS_DENIED = 1
12+
EC_NOT_A_FILE = 2
13+
EC_NOT_A_DIR = 3
14+
EC_NOT_A_PATH = 4
15+
EC_FILE_NOT_FOUND = 5
16+
EC_DIR_NOT_FOUND = 6
17+
EC_PATH_NOT_FOUND = 7
18+
EC_FILE_EXISTS = 8
19+
EC_DIR_EXISTS = 9
20+
EC_PATH_EXISTS = 10
21+
EC_NONEMPTY_DIR = 11
22+
EC_BROKEN_LINK = 12
23+
EC_INVALID_SCAN = 13
24+
"""
25+
@enum ErrorCode begin
26+
EC_INSTANTIATION_ERROR = -1
27+
EC_NOERROR = 0
28+
EC_ACCESS_DENIED = 1
29+
EC_NOT_A_FILE = 2
30+
EC_NOT_A_DIR = 3
31+
EC_NOT_A_PATH = 4
32+
EC_FILE_NOT_FOUND = 5
33+
EC_DIR_NOT_FOUND = 6
34+
EC_PATH_NOT_FOUND = 7
35+
EC_FILE_EXISTS = 8
36+
EC_DIR_EXISTS = 9
37+
EC_PATH_EXISTS = 10
38+
EC_NONEMPTY_DIR = 11
39+
EC_BROKEN_LINK = 12
40+
EC_INVALID_SCAN = 13
41+
end
42+
43+
# Package imports
344
import Downloads
445
import LibCURL
546
import URIs
@@ -8,12 +49,16 @@ import Logging
849
import Downloads: Downloader, Curl.Easy
950
import URIs: URI
1051

52+
# Curl error codes
53+
const CURLE_REMOTE_ACCESS_DENIED = 9
54+
55+
# File includes
1156
include("client.jl")
1257
include("fileexchange.jl")
1358
include("filestats.jl")
1459
include("filesystem.jl")
15-
include("deprecated.jl")
1660

61+
# Define API and export structs and functions
1762
@static if VERSION v"1.11"
1863
eval(Meta.parse("public Client, StatStruct, download, stat, filemode, ispath, isdir, isfile, islink, pwd, cd, mv, rm, mkdir, mkpath, readdir, walkdir, joinpath, splitdir, dirname, basename"))
1964
end

src/client.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ mutable struct Client
6969
verbose::Bool
7070
public_key_file::String
7171
private_key_file::String
72+
73+
function Client(
74+
downloader::Downloader,
75+
uri::URI,
76+
username::String,
77+
password::String,
78+
disable_verify_peer::Bool,
79+
disable_verify_host::Bool,
80+
verbose::Bool,
81+
public_key_file::String,
82+
private_key_file::String
83+
)::Client
84+
client = new(downloader, uri, username, password, disable_verify_peer, disable_verify_host, verbose, public_key_file, private_key_file)
85+
ispath(client, client.uri.path) || throw(Base.IOError("Cannot instantiate client; check user credentials and given uri path", Integer(EC_INSTANTIATION_ERROR)))
86+
return client
87+
end
7288
end
7389

7490

@@ -114,6 +130,7 @@ struct StatStruct
114130
if length(linkparts) == 2
115131
desc = linkparts[1]
116132
path = URIs.splitpath(linkparts[2])
133+
startswith(linkparts[2], "/") && pushfirst!(path, "") # ISSUE: URIs omits root slash in splitpath
117134
path = join(path[1:end - 1], "/")
118135
root *= " -> " * path
119136
end
@@ -181,7 +198,7 @@ end
181198

182199
## Overload Base functions
183200

184-
Base.show(io::IO, sftp::Client)::Nothing = println(io, "SFTP.Client(\"$(sftp.username)@$(sftp.uri.host)\")")
201+
Base.show(io::IO, sftp::Client)::Nothing = println(io, "SFTP.Client(\"$(sftp.username)@$(sftp.uri.host)\")")
185202

186203
Base.broadcastable(sftp::Client) = Ref(sftp)
187204

@@ -341,7 +358,7 @@ function findbase(stats::Vector{StatStruct}, base::AbstractString, path::Abstrac
341358
i = findfirst(isequal(base), pathnames)
342359
# Exception handling, if path is not found
343360
if isnothing(i)
344-
throw(Base.IOError("$path does not exist", -1))
361+
throw(Base.IOError("$path does not exist", Integer(EC_INVALID_SCAN)))
345362
end
346363
# Return index of base in stats
347364
return i

src/deprecated.jl

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)