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

Unified Diff: chrome/common/extensions/docs/server2/file_system.py

Issue 417163004: Docserver: Update Future.Then() to be more Promise-like (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/file_system.py
diff --git a/chrome/common/extensions/docs/server2/file_system.py b/chrome/common/extensions/docs/server2/file_system.py
index 99e33c5bbf7afbd166b6df577bbb2584be2e8600..1e5b567dab59b3b1eea7229f2416ac8695fab1e2 100644
--- a/chrome/common/extensions/docs/server2/file_system.py
+++ b/chrome/common/extensions/docs/server2/file_system.py
@@ -106,13 +106,12 @@ class FileSystem(object):
return Future(value=True)
parent, base = SplitParent(path)
- list_future = self.ReadSingle(ToDirectory(parent))
- def resolve():
- try:
- return base in list_future.Get()
- except FileNotFoundError:
+ def handle(error):
+ if isinstance(error, FileNotFoundError):
return False
- return Future(callback=resolve)
+ raise error
+ return self.ReadSingle(ToDirectory(parent)).Then(lambda l: base in l,
+ handle)
def Refresh(self):
'''Asynchronously refreshes the content of the FileSystem, returning a

Powered by Google App Engine
This is Rietveld 408576698