Skip to content

Commit 1cfdab5

Browse files
committed
Update Controller open_files when allocating file
1 parent 33642eb commit 1cfdab5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/volume_mgr.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ where
406406
open_files_row = Some(i);
407407
}
408408
}
409-
open_files_row.ok_or(Error::TooManyOpenDirs)
409+
open_files_row.ok_or(Error::TooManyOpenFiles)
410410
}
411411

412412
/// Delete a closed file with the given full path, if exists.
@@ -498,6 +498,12 @@ where
498498
file.starting_cluster = match &mut volume.volume_type {
499499
VolumeType::Fat(fat) => fat.alloc_cluster(self, None, false)?,
500500
};
501+
for f in self.open_files.iter_mut() {
502+
if f.1 == Cluster(0) {
503+
*f = (f.0, file.starting_cluster)
504+
}
505+
}
506+
501507
file.entry.cluster = file.starting_cluster;
502508
debug!("Alloc first cluster {:?}", file.starting_cluster);
503509
}

0 commit comments

Comments
 (0)