Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Fix a bug where multipart content-type header was used for subsequent…
Browse files Browse the repository at this point in the history
… requests.
  • Loading branch information
skarppi committed Aug 17, 2017
1 parent 5329a3b commit 541b7b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions photostation/photostation.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,26 +170,28 @@ def __str__(self):
',latitude:' + str(self.latitude) + \
',longitude:' + str(self.longitude) + '}'

@property
def fullpath(self):
return self.album.path + '/' + self.filename

# Merge with remote if able.
# Return false if rewrite is needed.
def merge(self):

fullpath = self.album.path + '/' + self.filename

remote = self.album.item(self.filename)
if remote is None \
or self.filename != remote.filename \
or self.filetype != remote.filetype:

print(self.filetype + ' ' + fullpath + ' not found or cannot be merged with ' + str(remote))
# print(self.filetype + ' ' + self.fullpath + ' not found or cannot be merged with ' + str(remote))
return False

if self.modified is not None and self.modified / 1000 > remote.modified / 1000:
print(self.filetype + ' ' + fullpath + ' timestamp differs, replacing existing ' + str(remote) + ' with ' + str(self))
print(self.filetype + ' ' + self.fullpath + ' timestamp differs, replacing existing ' + str(remote) + ' with ' + str(self))
return False

if self.filesize is not None and self.filesize != remote.filesize:
print(self.filetype + ' ' + fullpath + ' filesize differs, replacing existing ' + str(remote) + ' with ' + str(self))
print(self.filetype + ' ' + self.fullpath + ' filesize differs, replacing existing ' + str(remote) + ' with ' + str(self))
return False

changes = {}
Expand All @@ -205,7 +207,7 @@ def merge(self):
changes['gps_lng'] = self.longitude

if len(changes) > 0:
print(self.filetype + ' ' + fullpath + ' has metadata changes ' + str(changes) + ', updating existing ' + str(remote))
print(self.filetype + ' ' + self.fullpath + ' has metadata changes ' + str(changes) + ', updating existing ' + str(remote))
self.update(changes)

return True
Expand Down
4 changes: 2 additions & 2 deletions photostation/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, url):
self.url = url
self.session = requests.Session()

self.headers = None
self.headers = {}
self.info = {
'SYNO.API.Info': {
'path': 'query.php'
Expand All @@ -28,7 +28,7 @@ def query(self, api, data):
data.setdefault('api', api)
data.setdefault('version', 1)

headers=self.headers
headers=self.headers.copy()

if "original" in data:
data = MultipartEncoder(fields=data)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='photostation',
version='0.1.3',
version='0.1.4',
description='A Python API to communicate with Photo Station running on Synology NAS.',
long_description=long_description,
url='https://github.com/skarppi/python-photostation',
Expand Down

0 comments on commit 541b7b4

Please sign in to comment.