Skip to content

Commit 9b91003

Browse files
committed
fix: prevent file truncation when opening for read/write in FileCoordinator
1 parent 838b5ce commit 9b91003

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

moq-relay-ietf/src/bin/moq-relay-ietf/file_coordinator.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ fn unregister_namespace_sync(file_path: &Path, namespace: &TrackNamespace) -> Re
7777
.read(true)
7878
.write(true)
7979
.create(true)
80+
.truncate(false)
8081
.open(file_path)?;
8182

8283
file.lock_exclusive()?;
@@ -107,6 +108,7 @@ fn unregister_track_sync(
107108
.read(true)
108109
.write(true)
109110
.create(true)
111+
.truncate(false)
110112
.open(file_path)?;
111113

112114
file.lock_exclusive()?;
@@ -193,6 +195,7 @@ impl Coordinator for FileCoordinator {
193195
.read(true)
194196
.write(true)
195197
.create(true)
198+
.truncate(false)
196199
.open(&file_path)?;
197200

198201
file.lock_exclusive()?;
@@ -300,6 +303,7 @@ impl Coordinator for FileCoordinator {
300303
.read(true)
301304
.write(true)
302305
.create(true)
306+
.truncate(false)
303307
.open(&file_path)?;
304308

305309
file.lock_shared()?;
@@ -323,7 +327,6 @@ impl Coordinator for FileCoordinator {
323327
// instead of working on strings
324328
let is_prefix = registered_key
325329
.split('/')
326-
.into_iter()
327330
.zip(key.split('/'))
328331
.all(|(a, b)| a == b);
329332
match best_match {

0 commit comments

Comments
 (0)