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

add get_modified_time for sftp storage #1347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions storages/backends/sftpstorage.py
Expand Up @@ -9,6 +9,7 @@
import os
import posixpath
import stat
from datetime import datetime
from urllib.parse import urljoin

import paramiko
Expand Down Expand Up @@ -180,6 +181,16 @@ def size(self, name):
remote_path = self._remote_path(name)
return self.sftp.stat(remote_path).st_size

def get_accessed_time(self, name):
remote_path = self._remote_path(name)
utime = self.sftp.stat(remote_path).st_atime
return datetime.fromtimestamp(utime)

def get_modified_time(self, name):
remote_path = self._remote_path(name)
utime = self.sftp.stat(remote_path).st_mtime
return datetime.fromtimestamp(utime)

def url(self, name):
if self._base_url is None:
raise ValueError("This file is not accessible via a URL.")
Expand Down