From 9e2ed2df01cf427c1c1a63ba3f09bccfe175277d Mon Sep 17 00:00:00 2001
From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Tue, 8 Jan 2008 11:15:06 -0700
Subject: [PATCH] direct the user to docs/write_coordination.html in case of an
 UncoordinatedWriteError

---
 docs/write_coordination.html | 16 ++++++++++++++++
 src/allmydata/mutable.py     |  3 ++-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 docs/write_coordination.html

diff --git a/docs/write_coordination.html b/docs/write_coordination.html
new file mode 100644
index 00000000..8844ecde
--- /dev/null
+++ b/docs/write_coordination.html
@@ -0,0 +1,16 @@
+<!DOCtype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en">
+  <head>
+    <title>Avoiding Write Collisions in Tahoe</title>
+    <link rev="made" class="mailto" href="mailto:zooko[at]zooko[dot]com">
+    <meta name="description" content="how to avoid write collisions in Tahoe">
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <meta name="keywords" content="tahoe secure decentralized filesystem installation">
+  </head>
+
+  <body>
+    <h1>Write Collisions</h1>
+    <p>Tahoe does not provide locking of the mutable files and directories.  If there is more than one simultaneous attempt to change a mutable file or directory, then an <cite>UncoordinatedWriteError</p> will result.  This might, in rare cases, cause the file or directory contents to be accidentally deleted.  The user is expected to ensure that there is at most one outstanding write or update request for a given file or directory at a time.  One convenient way to accomplish this is to make a different file or directory for each person or process which wants to write.</p>
+
+  </body>
+</html>
diff --git a/src/allmydata/mutable.py b/src/allmydata/mutable.py
index 37d45980..c70061d8 100644
--- a/src/allmydata/mutable.py
+++ b/src/allmydata/mutable.py
@@ -27,7 +27,8 @@ class NeedMoreDataError(Exception):
         return "<NeedMoreDataError (%d bytes)>" % self.needed_bytes
 
 class UncoordinatedWriteError(Exception):
-    pass
+    def __repr__(self):
+        return "<%s -- You, oh user, tried to change a file or directory at the same time as another process was trying to change it.  To avoid data loss, don't do this.  Please see docs/write_coordination.html for details.>" % (self.__class__.__name__,)
 
 class CorruptShareError(Exception):
     def __init__(self, peerid, shnum, reason):
-- 
2.45.2