Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect local time zone in pipe fuse #1712

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pipe-cli/mount/pipefuse/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from datetime import datetime
from threading import RLock

import pytz
from dateutil.tz import tzlocal

from fsclient import File, FileSystemClientDecorator
import fuseutils
Expand Down Expand Up @@ -204,7 +204,7 @@ def _uncached_ls_as_dict(self, path, depth=1):
def _root(self):
return File(name='root',
size=0,
mtime=time.mktime(datetime.now(tz=pytz.utc).timetuple()),
mtime=time.mktime(datetime.now(tz=tzlocal()).timetuple()),
ctime=None,
contenttype=None,
is_dir=True)
Expand Down
6 changes: 3 additions & 3 deletions pipe-cli/mount/pipefuse/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
from datetime import datetime

import pytz
from dateutil.tz import tzlocal
from google.auth import _helpers
from google.auth.transport.requests import AuthorizedSession
from google.cloud.storage import Bucket, Blob, Client
Expand Down Expand Up @@ -252,15 +252,15 @@ def ls(self, path, depth=1):
def _get_file_object(self, blob, prefix, recursive):
return File(name=self._get_object_name(blob.name, prefix, recursive),
size=blob.size,
mtime=time.mktime(blob.updated.astimezone(pytz.utc).timetuple()),
mtime=time.mktime(blob.updated.astimezone(tzlocal()).timetuple()),
ctime=None,
contenttype='',
is_dir=False)

def _get_folder_object(self, name, prefix, recursive):
return File(name=self._get_object_name(name, prefix, recursive),
size=0,
mtime=time.mktime(datetime.now(tz=pytz.utc).timetuple()),
mtime=time.mktime(datetime.now(tz=tzlocal()).timetuple()),
ctime=None,
contenttype='',
is_dir=True)
Expand Down
3 changes: 2 additions & 1 deletion pipe-cli/mount/pipefuse/pipefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import time

import easywebdav
from dateutil.tz import tzlocal
from fuse import FuseOSError, Operations
from threading import RLock

Expand Down Expand Up @@ -139,7 +140,7 @@ def getattr(self, path, fh=None):
'st_mode': mode | self.mode,
'st_gid': os.getgid(),
'st_uid': os.getuid(),
'st_atime': time.mktime(datetime.datetime.now().timetuple())
'st_atime': time.mktime(datetime.datetime.now(tz=tzlocal()).timetuple())
}
if props.mtime:
attrs['st_mtime'] = props.mtime
Expand Down
6 changes: 3 additions & 3 deletions pipe-cli/mount/pipefuse/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import time
from datetime import datetime

import pytz
from boto3 import Session
from botocore.config import Config
from botocore.credentials import RefreshableCredentials
from botocore.session import get_session
from dateutil.tz import tzlocal

import fuseutils
from fsclient import File
Expand Down Expand Up @@ -210,7 +210,7 @@ def _matching_paths(self, items, path):
def get_folder_object(self, name):
return File(name=name,
size=0,
mtime=time.mktime(datetime.now(tz=pytz.utc).timetuple()),
mtime=time.mktime(datetime.now(tz=tzlocal()).timetuple()),
ctime=None,
contenttype='',
is_dir=True)
Expand All @@ -221,7 +221,7 @@ def get_file_name(self, file, prefix, recursive):
def get_file_object(self, file, name):
return File(name=name,
size=file.get('Size', ''),
mtime=time.mktime(file['LastModified'].astimezone(pytz.utc).timetuple()),
mtime=time.mktime(file['LastModified'].astimezone(tzlocal()).timetuple()),
ctime=None,
contenttype='',
is_dir=False)
Expand Down
4 changes: 3 additions & 1 deletion pipe-cli/mount/pipefuse/webdav.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
from numbers import Number

import easywebdav
import pytz
import requests
import urllib3
from dateutil.tz import tzlocal
from requests import cookies

import fuseutils
Expand Down Expand Up @@ -109,7 +111,7 @@ def parse_timestamp(self, value, date_format):
return
try:
time_value = datetime.datetime.strptime(value, date_format)
return time.mktime(time_value.timetuple())
return time.mktime(time_value.replace(tzinfo=pytz.UTC).astimezone(tzlocal()).timetuple())
except ValueError as e:
logging.error(
'Failed to parse date: %s. Expected format: "%s". Error: "%s"' % (value, date_format, str(e)))
Expand Down
1 change: 1 addition & 0 deletions pipe-cli/mount/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cachetools==3.1.1
python-intervals==1.10.0
google-resumable-media==0.3.2
google-cloud-storage==1.15.0
python-dateutil=2.8.1