about summary refs log tree commit diff stats
path: root/088file.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-12-11 15:31:04 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-12-11 15:31:04 -0800
commitd5c86dfd8706e6b3ceee7843464797e6fcad4259 (patch)
tree34f07b48140270e32e0a3eefe136ece090db2170 /088file.mu
parente7f65b0a4b0af23f5107fb44b8dc39514411589d (diff)
downloadmu-d5c86dfd8706e6b3ceee7843464797e6fcad4259.tar.gz
3704
Bugfix: writing to a new file in a non-empty fake file system.

The one time I try to get a little clever, it bites me in the ass.
That'll teach me..
Diffstat (limited to '088file.mu')
-rw-r--r--088file.mu12
1 files changed, 8 insertions, 4 deletions
diff --git a/088file.mu b/088file.mu
index e91723ab..b7358327 100644
--- a/088file.mu
+++ b/088file.mu
@@ -137,10 +137,13 @@ def transmit-to-fake-file resources:&:resources, filename:text, source:&:source:
     tmp:resource <- index *data, i
     curr-filename <- get tmp, name:offset
     found?:bool <- equal filename, curr-filename
-    loop-unless found?
-    put-index *data, i, new-resource
-    reset lock
-    return
+    {
+      break-unless found?
+      put-index *data, i, new-resource
+      jump +unlock-and-exit
+    }
+    i <- add i, 1
+    loop
   }
   # if file didn't already exist, make room for it
   new-len:num <- add len, 1
@@ -156,5 +159,6 @@ def transmit-to-fake-file resources:&:resources, filename:text, source:&:source:
   }
   # write new file
   put-index *new-data, len, new-resource
+  +unlock-and-exit
   reset lock
 ]