Index: chrome/common/extensions/docs/server2/gcs_file_system.py |
diff --git a/chrome/common/extensions/docs/server2/gcs_file_system.py b/chrome/common/extensions/docs/server2/gcs_file_system.py |
index d1c3820fe7226f3ce387965f6a899f65f453b188..11d6c442100d5df9560d97c85de826004a89bb4b 100644 |
--- a/chrome/common/extensions/docs/server2/gcs_file_system.py |
+++ b/chrome/common/extensions/docs/server2/gcs_file_system.py |
@@ -13,6 +13,10 @@ from future import Gettable, Future |
import logging |
import traceback |
+# Name of the file containing the Git hash of the latest commit sync'ed |
+# to Cloud Storage. This file is generated by the Github->GCS sync script |
+LAST_COMMIT_HASH_FILENAME='.__lastcommit.txt' |
+ |
'''See gcs_file_system_provider.py for documentation on using Google Cloud |
Storage as a filesystem. |
''' |
@@ -35,30 +39,25 @@ def _ListDir(dir_name): |
def _CreateStatInfo(bucket, path): |
bucket = '/%s' % bucket |
full_path = '/'.join( (bucket, path.lstrip('/')) ) |
+ last_commit_file = '%s/%s' % (bucket, LAST_COMMIT_HASH_FILENAME) |
try: |
+ last_commit = _ReadFile(last_commit_file) |
if full_path.endswith('/'): |
child_versions = dict() |
- version = 0 |
# Fetching stats for all files under full_path, recursively. The |
# listbucket method uses a prefix approach to simulate hierarchy, |
# but calling it without the "delimiter" argument searches for prefix, |
# which means, for directories, everything beneath it. |
for _file in cloudstorage_api.listbucket(full_path): |
- if not _file.is_dir: |
- # GCS doesn't have metadata for dirs |
- child_stat = cloudstorage_api.stat('%s' % _file.filename).st_ctime |
- filename = _file.filename[len(bucket)+1:] |
- child_versions[filename] = child_stat |
- version = max(version, child_stat) |
+ filename = _file.filename[len(full_path):] |
+ child_versions[filename] = last_commit |
else: |
child_versions = None |
- version = cloudstorage_api.stat(full_path).st_ctime |
- return StatInfo(version, child_versions) |
+ return StatInfo(last_commit, child_versions) |
except (TypeError, errors.Error): |
raise FileNotFoundError('cloudstorage.stat failed for %s: %s' % (path, |
traceback.format_exc())) |
- |
class CloudStorageFileSystem(FileSystem): |
'''FileSystem implementation which fetches resources from Google Cloud |
Storage. |