about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--crates/yt/src/select/mod.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/yt/src/select/mod.rs b/crates/yt/src/select/mod.rs
index 76d5ae8..b39bea2 100644
--- a/crates/yt/src/select/mod.rs
+++ b/crates/yt/src/select/mod.rs
@@ -138,8 +138,9 @@ pub(crate) async fn select_split(
     paths.sort();
 
     let mut persistent_file = OpenOptions::new()
-        .read(true)
+        .read(false)
         .write(true)
+        .create(true)
         .truncate(true)
         .open(&app.config.paths.last_selection_path)
         .context("Failed to open persistent selection file")?;
@@ -152,7 +153,14 @@ pub(crate) async fn select_split(
         persistent_file.write_all(&buffer)?;
     }
 
-    persistent_file.rewind()?;
+    persistent_file.flush()?;
+    let persistent_file = OpenOptions::new()
+        .read(true)
+        .open(format!(
+            "/proc/self/fd/{}",
+            persistent_file.as_fd().as_raw_fd()
+        ))
+        .context("Failed to re-open persistent file")?;
 
     let processed = process_file(app, &persistent_file).await?;
 
@@ -179,7 +187,7 @@ pub(crate) async fn select_file(app: &App, done: bool, use_last_selection: bool)
 
     open_editor_at(temp_file.path()).await?;
 
-    let read_file = temp_file.reopen()?;
+    let read_file = OpenOptions::new().read(true).open(temp_file.path())?;
     fs::copy(temp_file.path(), &app.config.paths.last_selection_path)
         .context("Failed to persist selection file")?;