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

Commit

Permalink
Merge pull request #100 from gilesknap/feature
Browse files Browse the repository at this point in the history
umask fix
  • Loading branch information
gilesknap authored Jul 31, 2019
2 parents f39cd30 + 27407ac commit bdc6797
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions gphotos/GooglePhotosDownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def __init__(self, api: RestClient, root_folder: Path, db: LocalData):
self.pool_future_to_media = {}
self.bad_ids = BadIds(self._root_folder)

self.current_umask = os.umask(7)
os.umask(self.current_umask)

self._session = requests.Session()
retries = Retry(total=5,
backoff_factor=0.1,
Expand Down Expand Up @@ -214,15 +217,19 @@ def do_download_file(self, base_url: str, media_item: DatabaseMedia):
response.raise_for_status()
shutil.copyfileobj(response.raw, temp_file)
temp_file.close()
temp_file = None
response.close()
t_path.rename(local_full_path)
os.utime(str(local_full_path),
(Utils.safe_timestamp(media_item.modify_date),
Utils.safe_timestamp(media_item.create_date)))
os.chmod(str(local_full_path), 0o666 & ~self.current_umask)
except KeyboardInterrupt:
log.debug("User cancelled download thread")
raise
finally:
if temp_file:
temp_file.close()
if t_path.exists():
t_path.unlink()

Expand Down
2 changes: 1 addition & 1 deletion test/test_credentials/.gphotos.token
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"access_token": "ya29.Gl1TB5NQa81-cIxQrGNHfK74iQPnCbt08qS5_9RtZyGjGyQagXh2ggwFz91sQCrZU7aIa_w0aQ6e40hKawR_Lby5-12q1SBQKAWXkCPiTGmWpPe2fghI5g7P9wN8k0c", "expires_in": 3600, "scope": ["https://www.googleapis.com/auth/photoslibrary.sharing", "https://www.googleapis.com/auth/photoslibrary.readonly"], "token_type": "Bearer", "expires_at": 1564319120.143785, "refresh_token": "1/HG0feqbbu7FZLjztEbGneV0Jz2aNoiNYuFIHvcZ9MgQ"}
{"access_token": "ya29.Gl1WB4CwD_sE9T0LnmkMSSjesZknrhxOdf0sJ-uxlFOgAFfPz29YbCdn05RuQ4XZEGXXdh0ykeM3HVk0ufMQTxElwBPFmvN4OmzwcAgRNI-L4DWGszwEfyt1XHt_vOo", "expires_in": 3600, "scope": ["https://www.googleapis.com/auth/photoslibrary.sharing", "https://www.googleapis.com/auth/photoslibrary.readonly"], "token_type": "Bearer", "expires_at": 1564572955.0487018, "refresh_token": "1/HG0feqbbu7FZLjztEbGneV0Jz2aNoiNYuFIHvcZ9MgQ"}

0 comments on commit bdc6797

Please sign in to comment.