Skip to content

Commit

Permalink
fix name too long error
Browse files Browse the repository at this point in the history
  • Loading branch information
cihga39871 committed Sep 18, 2024
1 parent 497d755 commit 5375046
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Pipelines"
uuid = "ef544631-5c6f-4e9b-994c-12e7a4cd724c"
authors = ["Jiacheng Chuan <jiacheng_chuan@outlook.com>"]
version = "0.11.0"
version = "0.11.1"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
4 changes: 4 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v0.11.1

- Fix: use `tryisfile(f)` instead of `isfile(f)` in `cmd_to_run_id_lines` because the latter might cause name too long error.

## v0.11.0

- Feat/**Breaking**: new method `auto_change_directory(b::Bool)`. It is necessary because changing directory is not thread-safe in Julia. It was set to `false` in v0.11.0. To make your code compatible with previous version, you can add `Pipelines.auto_change_directory(true)` at the beginning of your code, or use full paths through out your code (recommended).
Expand Down
22 changes: 17 additions & 5 deletions src/run_id_file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ function write_run_id_line(io, arg_name::AbstractString, file::AbstractString, f
end
write_run_id_line(io, arg_name::AbstractPath, file::AbstractString, first_char::String; skip_ext::Vector = RUN_ID_LINE_SKIP_EXTENSION) = write_run_id_line(io, string(arg_name), file, first_char; skip_ext = skip_ext)

"""
tryisfile(f)
if name too long
"""
function tryisfile(f)
try
isfile(f)
catch
false
end
end

"""
cmd_to_run_id_lines(io::IO, arg_name::AbstractString, cmd::Base.AbstractCmd, first_char::String)
Expand Down Expand Up @@ -303,29 +315,29 @@ function cmd_to_run_id_lines(io::IO, arg_name::AbstractString, cmd::Cmd, first_c
end

f = m.captures[1]
if isfile(f)
if tryisfile(f)
write_run_id_line(io, arg_name, f, first_char)
else
# check whether it is file1,file2 or file1;file2
splited = split(f, CMD_FILE_SPLITER)
length(splited) == 1 && continue
for s in splited
if isfile(s)
if tryisfile(s)
write_run_id_line(io, arg_name, s, first_char)
end
end
end
continue
end

if isfile(arg)
if tryisfile(arg)
write_run_id_line(io, arg_name, arg, first_char)
else
# check whether it is file1,file2 or file1;file2
splited = split(arg, CMD_FILE_SPLITER)
length(splited) == 1 && continue
for f in splited
if isfile(f)
if tryisfile(f)
write_run_id_line(io, arg_name, f, first_char)
end
end
Expand All @@ -345,7 +357,7 @@ function cmd_to_run_id_lines(io::IO, arg_name::AbstractString, h::Base.TTY, firs
nothing
end
function cmd_to_run_id_lines(io::IO, arg_name::AbstractString, h::Base.FileRedirect, first_char::String) # h: handle property of CmdRedirect
if isfile(h.filename)
if tryisfile(h.filename)
write_run_id_line(io, arg_name, h.filename, first_char)
end
end

0 comments on commit 5375046

Please sign in to comment.