studio-b12 / gowebdav

A golang WebDAV client library and command line tool.
BSD 3-Clause "New" or "Revised" License
309 stars 89 forks source link

Allows to disable making parent collection while writing stream #76

Open the-plate opened 1 year ago

the-plate commented 1 year ago

Sometimes it is useful and also not necessary to call the createParentCollection(). Hence, a bool param is introduced disabling the function call.

chripo commented 1 year ago

Thanks for your feature.

We could move this to a global option/setter to make this work for all operations. Or a refactoring into a decorator that handles the recursive collection creation.

Discussions are welcome.

the-plate commented 1 year ago

What do you mean by 'all operations'? If I see it right, there are only 3 occurrence of the createParentCollection(). Hence, by global option is meant an additional Client param e.g. skipcreateParents, which would be than checked before each createParentCollection() call... ?

chripo commented 1 year ago

yes. this PR captures just one call to createPatentCollection(). as a Client setter createPatentCollection(true|false) would make the feature available for all present and future write operations. the check would be done inside createPatentCollection(path).

the-plate commented 1 year ago

Hence, I've adjusted the changes based on your thoughts and suggestion. Please have a look at it.

ueffel commented 1 year ago

Just my opinions:

the-plate commented 1 year ago

@ueffel thanks for the insight! First, yes you're right about the placement of variadic arg. It is used to ensure compatibility. Second, personally to parametrize the createParentCollection(bool) is not the prefered way for me either, I would keep it like it is now. Instead, I would parametrize the Write or any other method calling the createParentCollection() fcn to be or not to be called via a condition statement, as you pointed out. Third and to sum up - I agree with your suggestion, I see it quite the same in respect to the point 2. Therefore, I'll modify it based on the suggestion from point 1.

chripo commented 1 year ago

I would not be in favor of more method arguments for feature toggling. For the shake of consistency, I'd prefer a global flag, it's KISS. Or some kind of Client decorator witch takes care of parent collections. The basic intent of the project is to be consistent with a file API.