Skip to content
Prev Previous commit
Next Next commit
[LIB-852] allow to create file when updating non exsiting;
  • Loading branch information
opalczynski committed Aug 29, 2016
commit d7b0d83ced094cfba57c9eca7ba02e4f1e025e98
5 changes: 4 additions & 1 deletion syncano/models/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ def update_file(self, path, file):
"""
hosting_files = self._get_files()
is_found = False

for hosting_file in hosting_files:
if hosting_file.path == path:
is_found = True
break

if not is_found:
raise SyncanoRequestError('File with path {} not found.'.format(path))
# create if not found;
hosting_file = self.upload_file(path, file)
return hosting_file

connection = self._get_connection()
headers = self._prepare_header(connection)
Expand Down