otiai10 / copy

Go copy directory recursively
https://pkg.go.dev/github.com/otiai10/copy
MIT License
722 stars 115 forks source link

Let caller hander error cases #101

Closed michalpristas closed 1 year ago

michalpristas commented 1 year ago

Please consider this. This PR introduces onErr option in a form of func(error)error which lets caller to handler error cases . It enables caller to log error by error and gives a possibility to continue with copying in case error is not that severe by returning nil (swallowing an error).

codecov[bot] commented 1 year ago

Codecov Report

Merging #101 (b348b50) into main (dfe4363) will increase coverage by 1.03%. The diff coverage is 100.00%.

:exclamation: Current head b348b50 differs from pull request most recent head 2abaf6c. Consider uploading reports for the commit 2abaf6c to get more accurate results

@@            Coverage Diff             @@
##             main     #101      +/-   ##
==========================================
+ Coverage   78.33%   79.36%   +1.03%     
==========================================
  Files           9        9              
  Lines         180      189       +9     
==========================================
+ Hits          141      150       +9     
  Misses         19       19              
  Partials       20       20              
Impacted Files Coverage Δ
options.go 83.33% <ø> (ø)
copy.go 80.32% <100.00%> (+1.56%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

otiai10 commented 1 year ago

in case error is not that severe

Can you give me some example of this?

michalpristas commented 1 year ago

what i'm facing is a case when (on windows) directory copy fails because another process is reading a single file. what i'd like to do here is to have a hook so I can decide on severity, and skip file if it's not critical for me

otiai10 commented 1 year ago

@otiai10 will check in 24 hours