Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/common/extensions/docs/server2/github_file_system.py

Issue 10871002: Extensions Docs Server: Testing GithubFileSystem and cron jobs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import os 6 import os
7 7
8 import appengine_blobstore as blobstore 8 import appengine_blobstore as blobstore
9 import object_store 9 import object_store
10 from file_system import FileSystem, StatInfo 10 from file_system import FileSystem, StatInfo
(...skipping 11 matching lines...) Expand all
22 self._fetch = fetcher.FetchAsync(ZIP_KEY) 22 self._fetch = fetcher.FetchAsync(ZIP_KEY)
23 self._blobstore = blobstore 23 self._blobstore = blobstore
24 self._new_version = new_version 24 self._new_version = new_version
25 self._old_version = old_version 25 self._old_version = old_version
26 26
27 def Get(self): 27 def Get(self):
28 blob = self._fetch.Get().content 28 blob = self._fetch.Get().content
29 self._blobstore.Set(_MakeKey(self._new_version), 29 self._blobstore.Set(_MakeKey(self._new_version),
30 blob, 30 blob,
31 blobstore.BLOBSTORE_GITHUB) 31 blobstore.BLOBSTORE_GITHUB)
32 self._blobstore.Delete(_MakeKey(self._old_version), 32 if self._old_version != self._new_version:
not at google - send to devlin 2012/08/22 13:57:58 This "old version" vs "new version" thing is a bit
cduvall 2012/08/22 17:20:43 Done.
33 blobstore.BLOBSTORE_GITHUB) 33 self._blobstore.Delete(_MakeKey(self._old_version),
34 blobstore.BLOBSTORE_GITHUB)
34 return ZipFile(BytesIO(blob)) 35 return ZipFile(BytesIO(blob))
35 36
36 class GithubFileSystem(FileSystem): 37 class GithubFileSystem(FileSystem):
37 """FileSystem implementation which fetches resources from github. 38 """FileSystem implementation which fetches resources from github.
38 """ 39 """
39 def __init__(self, fetcher, object_store, blobstore): 40 def __init__(self, fetcher, object_store, blobstore):
40 self._fetcher = fetcher 41 self._fetcher = fetcher
41 self._object_store = object_store 42 self._object_store = object_store
42 self._blobstore = blobstore 43 self._blobstore = blobstore
43 self._version = self.Stat(ZIP_KEY).version 44 self._version = self.Stat(ZIP_KEY).version
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 self._GetZip(version) 76 self._GetZip(version)
76 result = {} 77 result = {}
77 for path in paths: 78 for path in paths:
78 if path.endswith('/'): 79 if path.endswith('/'):
79 result[path] = self._ListDir(path) 80 result[path] = self._ListDir(path)
80 else: 81 else:
81 result[path] = self._ReadFile(path) 82 result[path] = self._ReadFile(path)
82 return Future(value=result) 83 return Future(value=result)
83 84
84 def Stat(self, path): 85 def Stat(self, path):
85 version = self._object_store.Get(path, object_store.GITHUB_STAT) 86 version = self._object_store.Get(path, object_store.GITHUB_STAT).Get()
86 if version is not None: 87 if version is not None:
87 return StatInfo(version) 88 return StatInfo(version)
88 version = json.loads( 89 version = json.loads(
89 self._fetcher.Fetch('commits/HEAD').content)['commit']['tree']['sha'] 90 self._fetcher.Fetch('commits/HEAD').content)['commit']['tree']['sha']
90 self._object_store.Set(path, version, object_store.GITHUB_STAT) 91 self._object_store.Set(path, version, object_store.GITHUB_STAT)
91 return StatInfo(version) 92 return StatInfo(version)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698