From 3e996e0c94e9778717e18927e2d05d67fd6490c0 Mon Sep 17 00:00:00 2001
From: Kevan Carstensen <kevan@isnotajoke.com>
Date: Mon, 1 Aug 2011 19:08:14 -0700
Subject: [PATCH] immutable/literal.py: Implement interface changes in literal
 nodes.

---
 src/allmydata/immutable/literal.py  | 12 ++++++++++++
 src/allmydata/test/test_filenode.py | 14 ++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/src/allmydata/immutable/literal.py b/src/allmydata/immutable/literal.py
index 09466cb8..16effaa4 100644
--- a/src/allmydata/immutable/literal.py
+++ b/src/allmydata/immutable/literal.py
@@ -102,3 +102,15 @@ class LiteralFileNode(_ImmutableFileNodeBase):
         d = basic.FileSender().beginFileTransfer(StringIO(data), consumer)
         d.addCallback(lambda lastSent: consumer)
         return d
+
+    # IReadable, IFileNode, IFilesystemNode
+    def get_best_readable_version(self):
+        return defer.succeed(self)
+
+
+    def download_best_version(self):
+        return defer.succeed(self.u.data)
+
+
+    download_to_data = download_best_version
+    get_size_of_best_version = get_current_size
diff --git a/src/allmydata/test/test_filenode.py b/src/allmydata/test/test_filenode.py
index 61bb0e8e..abc74981 100644
--- a/src/allmydata/test/test_filenode.py
+++ b/src/allmydata/test/test_filenode.py
@@ -95,6 +95,20 @@ class Node(unittest.TestCase):
         def _check_segment(res):
             self.failUnlessEqual(res, DATA[1:1+5])
         d.addCallback(_check_segment)
+        d.addCallback(lambda ignored: fn1.get_best_readable_version())
+        d.addCallback(lambda fn2: self.failUnlessEqual(fn1, fn2))
+        d.addCallback(lambda ignored:
+            fn1.get_size_of_best_version())
+        d.addCallback(lambda size:
+            self.failUnlessEqual(size, len(DATA)))
+        d.addCallback(lambda ignored:
+            fn1.download_to_data())
+        d.addCallback(lambda data:
+            self.failUnlessEqual(data, DATA))
+        d.addCallback(lambda ignored:
+            fn1.download_best_version())
+        d.addCallback(lambda data:
+            self.failUnlessEqual(data, DATA))
 
         return d
 
-- 
2.45.2