N4S4 / synology-api

A Python wrapper around Synology API
MIT License
368 stars 138 forks source link

Issues using additional parameters during get_file_info() #75

Closed MarinBons closed 2 years ago

MarinBons commented 2 years ago

Hello ! Thanks for the amazing project :) I have got some issues using multiple additional parameters while using get_file_info method

Neither : fl.get_file_info(path,additional = {'size','time','real_path'}) or fl.get_file_info(path,additional = ['size','time','real_path']) works.

I only have one parameter working or less, like when I use it this way : fl.get_file_info(path',additional = 'size')

I only have the results like this, so with only one parameter (size, time, real_path or owner) working {'data': {'files': [{'additional': {'size': 3342336}, 'isdir': False, 'name': 'file_name', 'path': '/path'}]}, 'success': True}

N4S4 commented 2 years ago

So if i understand correctly, requesting one parameter only it works otherwise it doesn't? Did you tey to leave it = None?

MarinBons commented 2 years ago

Yes indeed. I've tried and I get a result without information about size, time, real path or owner 🤷‍♂️

N4S4 commented 2 years ago

Mmm ok I will need to look into it

AustinAres2007 commented 2 years ago

As of May 20th 2022, this still has not been fixed.

N4S4 commented 2 years ago

True, unfortunately time has not been on my side...I will make some tests

AustinAres2007 commented 2 years ago

True, unfortunately time has not been on my side...I will make some tests

Does it work for others? I am looking at the code and the "additional" parameter is handled differently

A fix I came up with in the get_file_list and get_file_info functions, it is to:

Remove the:

if type(additional) is list:
    additional = ','.join(additional)

part and replace it with:

additional = str(additional).replace("'", '"')

This works for my use case. I believe it is todo with requests.get. It does not seem to like single quotes. And leave additional as a list, but the type is converted to a string. And replace single quotes with double quotes.

Also sorry if I'm not making sense, just 14 and still learning this "trade". Thanks for this package as well, very useful.

N4S4 commented 2 years ago

Any help and suggestion are always welcome! So thank you! It was working for me when I used couple months ago, however later tonight I will run few tests and see what is going on

N4S4 commented 2 years ago

So it looks like when it was requested one additional parameter only worked but not if you request more than one, apparently the request type needs to be packed as list string and not processed, however your fix worked! thank you I will update the code