From 62c72881bb20c77e170a56051c8fe6bcfba6dea0 Mon Sep 17 00:00:00 2001
From: Kevan Carstensen <kevan@isnotajoke.com>
Date: Sat, 13 Aug 2011 14:00:05 -0700
Subject: [PATCH] mutable/filenode.py: don't fetch more segments than necesasry
 to update the file

---
 src/allmydata/mutable/filenode.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/allmydata/mutable/filenode.py b/src/allmydata/mutable/filenode.py
index 1d2f2692..e798a589 100644
--- a/src/allmydata/mutable/filenode.py
+++ b/src/allmydata/mutable/filenode.py
@@ -1114,6 +1114,9 @@ class MutableFileVersion:
         end_segment = start_segment
         if offset + data.get_size() < self.get_size():
             end_data = offset + data.get_size()
+            # The last byte we touch is the end_data'th byte, which is actually
+            # byte end_data - 1 because bytes are zero-indexed.
+            end_data -= 1
             end_segment = end_data // segsize
 
         self._start_segment = start_segment
-- 
2.45.2