From 4b5927fdb868742563601ceb7c71831b1aae4ae4 Mon Sep 17 00:00:00 2001
From: david-sarah <david-sarah@jacaranda.org>
Date: Mon, 7 Jun 2010 23:37:53 -0700
Subject: [PATCH] SFTP: suppress NoSuchChildError if heisenfile attributes have
 been updated in setAttrs, in the case where the parent is available.

---
 src/allmydata/frontends/sftpd.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/allmydata/frontends/sftpd.py b/src/allmydata/frontends/sftpd.py
index e09d845c..5d54962b 100644
--- a/src/allmydata/frontends/sftpd.py
+++ b/src/allmydata/frontends/sftpd.py
@@ -1162,6 +1162,7 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
 
         def _done(ign):
             self.log("done %r" % (request,), level=OPERATIONAL)
+            # TODO: this should not return True if only_if_at caused all files to be skipped.
             return len(files) > 0
         d.addBoth(_done)
         return d
@@ -1707,7 +1708,14 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
                     desired_metadata = _attrs_to_metadata(attrs)
                     if noisy: self.log("desired_metadata = %r" % (desired_metadata,), level=NOISY)
 
-                    return parent_or_node.set_metadata_for(childname, desired_metadata)
+                    d3 = parent_or_node.set_metadata_for(childname, desired_metadata)
+                    def _nosuch(err):
+                        if updated_heisenfiles:
+                            err.trap(NoSuchChildError)
+                        else:
+                            return err
+                    d3.addErrback(_nosuch)
+                    return d3
             d2.addCallback(_update)
             d2.addCallback(lambda ign: None)
             return d2
-- 
2.45.2