Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recursive put file logic #9744

Merged
merged 4 commits into from Feb 16, 2024
Merged

Fix recursive put file logic #9744

merged 4 commits into from Feb 16, 2024

Conversation

BOsterbuhr
Copy link
Contributor

This PR corrects an issue I introduced in #9636.

Now after this PR the behavior has been corrected so the files are put at the root.

This PR also adds two tests that cover pachctl put file repo@branch:/ -r -f /path/to/dir --full-path and pachctl put file repo@branch:/ -r -f /path/to/dir

@BOsterbuhr BOsterbuhr requested a review from a team as a code owner February 15, 2024 23:04
Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (1b25a53) 59.37% compared to head (af59517) 59.40%.
Report is 9 commits behind head on master.

Files Patch % Lines
src/server/pfs/cmds/cmds.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9744      +/-   ##
==========================================
+ Coverage   59.37%   59.40%   +0.02%     
==========================================
  Files         583      583              
  Lines       71139    71139              
==========================================
+ Hits        42242    42258      +16     
+ Misses      28277    28249      -28     
- Partials      620      632      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
if err := putFileHelper(mf, finalPath, source, recursive, appendFile, untar); err != nil {
return err
if recursive {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could just be

finalPath := file.Path
if recursive && fullPath || !recursive && strings.HasSuffix(file.Path, "/") {
        finalPath = joinPaths(file.Path, target)
}
if err := putFileHelper(mf, finalPath, source, recursive, appendFile, untar); err != nil {
    return err
}

Co-Authored-By: Bryce McAnally <bryce@pachyderm.io>
Copy link
Contributor

@brycemcanally brycemcanally left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@BOsterbuhr BOsterbuhr merged commit 439234a into master Feb 16, 2024
21 checks passed
@BOsterbuhr BOsterbuhr deleted the bosterbuhr/put-file-dir-fix branch February 16, 2024 20:05
BOsterbuhr added a commit that referenced this pull request Feb 16, 2024
This PR corrects an issue introduced in #9636.

- Before #9636 when you ran `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you would
end up with two files `repo@branch:/a.txt` and `repo@branch:/b.txt"`
- After #9636 when running `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you end
up with two files with the `dir` prefix: `repo@branch:/dir/a.txt` and
`repo@branch:/dir/b.txt`

Now after this PR the behavior has been corrected so the files are put
at the root.

This PR also adds two tests that cover `pachctl put file repo@branch:/
-r -f /path/to/dir --full-path` and `pachctl put file repo@branch:/ -r
-f /path/to/dir`

---------

Co-authored-by: Bryce McAnally <bryce@pachyderm.io>
BOsterbuhr added a commit that referenced this pull request Feb 16, 2024
This PR corrects an issue introduced in #9636.

- Before #9636 when you ran `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you would
end up with two files `repo@branch:/a.txt` and `repo@branch:/b.txt"`
- After #9636 when running `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you end
up with two files with the `dir` prefix: `repo@branch:/dir/a.txt` and
`repo@branch:/dir/b.txt`

Now after this PR the behavior has been corrected so the files are put
at the root.

This PR also adds two tests that cover `pachctl put file repo@branch:/
-r -f /path/to/dir --full-path` and `pachctl put file repo@branch:/ -r
-f /path/to/dir`

---------

Co-authored-by: Bryce McAnally <bryce@pachyderm.io>
BOsterbuhr added a commit that referenced this pull request Feb 20, 2024
This PR corrects an issue introduced in #9636.

- Before #9636 when you ran `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you would
end up with two files `repo@branch:/a.txt` and `repo@branch:/b.txt"`
- After #9636 when running `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you end
up with two files with the `dir` prefix: `repo@branch:/dir/a.txt` and
`repo@branch:/dir/b.txt`

Now after this PR the behavior has been corrected so the files are put
at the root.

This PR also adds two tests that cover `pachctl put file repo@branch:/
-r -f /path/to/dir --full-path` and `pachctl put file repo@branch:/ -r
-f /path/to/dir`

---------

Co-authored-by: Bryce McAnally <bryce@pachyderm.io>
zmajeed pushed a commit that referenced this pull request Feb 21, 2024
This PR corrects an issue introduced in #9636.

- Before #9636 when you ran `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you would
end up with two files `repo@branch:/a.txt` and `repo@branch:/b.txt"`
- After #9636 when running `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you end
up with two files with the `dir` prefix: `repo@branch:/dir/a.txt` and
`repo@branch:/dir/b.txt`

Now after this PR the behavior has been corrected so the files are put
at the root.

This PR also adds two tests that cover `pachctl put file repo@branch:/
-r -f /path/to/dir --full-path` and `pachctl put file repo@branch:/ -r
-f /path/to/dir`

---------

Co-authored-by: Bryce McAnally <bryce@pachyderm.io>
BOsterbuhr added a commit that referenced this pull request Feb 21, 2024
This PR corrects an issue introduced in #9636.

- Before #9636 when you ran `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you would
end up with two files `repo@branch:/a.txt` and `repo@branch:/b.txt"`
- After #9636 when running `pachctl put file repo@branch:/ -r -f
/path/to/dir` and `/path/to/dir` has files `a.txt` and `b.txt` you end
up with two files with the `dir` prefix: `repo@branch:/dir/a.txt` and
`repo@branch:/dir/b.txt`

Now after this PR the behavior has been corrected so the files are put
at the root.

This PR also adds two tests that cover `pachctl put file repo@branch:/
-r -f /path/to/dir --full-path` and `pachctl put file repo@branch:/ -r
-f /path/to/dir`

---------

Co-authored-by: Bryce McAnally <bryce@pachyderm.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants