Skip to content

Commit 688f35c

Browse files
committed
fix(dir-structure): fix lint
1 parent 2bd27c3 commit 688f35c

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/dev/dir-structure/src/atomic_dir.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,12 @@ where
285285
match fut.as_mut().poll(cx) {
286286
Poll::Ready(result) => {
287287
*self = Self::Done;
288-
return Poll::Ready(result);
288+
Poll::Ready(result)
289+
}
290+
Poll::Pending => {
291+
self.as_mut().project_replace(Self::PersistingTempDir(fut));
292+
Poll::Pending
289293
}
290-
Poll::Pending => return Poll::Pending,
291294
}
292295
}
293296
AtomicDirWriteToAsyncRefFutureProj::DeletingTempDir(mut fut, error) => {

src/dev/dir-structure/src/vfs/fs_vfs.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ mod imp {
136136
pub(crate) mod atomic_dir_imp {
137137
//! The [`VfsSupportsTemporaryDirectories`] implementation for the [`FsVfs`] file system.
138138
139+
use std::env;
140+
use std::fs;
141+
use std::mem;
142+
use std::process;
139143
use std::sync::atomic::AtomicU64;
144+
use std::sync::atomic::Ordering;
140145

141146
use super::*;
142147
use crate::atomic_dir::TempDirApi;
@@ -158,23 +163,23 @@ pub(crate) mod atomic_dir_imp {
158163
path: &<Self::Vfs as VfsCore>::Path,
159164
) -> VfsResult<(), Self::Vfs> {
160165
vfs.create_parent_dir(path)?;
161-
std::fs::rename(&self.0, path).wrap_io_error_with(path)?;
166+
fs::rename(&self.0, path).wrap_io_error_with(path)?;
162167
// do not run the Drop impl, as we already moved the directory
163-
std::mem::forget(self);
168+
mem::forget(self);
164169
Ok(())
165170
}
166171

167172
fn delete(self, vfs: Pin<&'vfs Self::Vfs>) -> VfsResult<(), Self::Vfs> {
168173
vfs.remove_dir_all(&self.0)?;
169174
// do not run the Drop impl, as we already deleted the directory
170-
std::mem::forget(self);
175+
mem::forget(self);
171176
Ok(())
172177
}
173178
}
174179

175180
impl Drop for TempDir {
176181
fn drop(&mut self) {
177-
let _ = std::fs::remove_dir_all(&self.0);
182+
let _ = fs::remove_dir_all(&self.0);
178183
}
179184
}
180185

@@ -202,10 +207,10 @@ pub(crate) mod atomic_dir_imp {
202207
}
203208

204209
pub fn make_new_temp_dir_path() -> PathBuf {
205-
std::env::temp_dir().join(format!(
210+
env::temp_dir().join(format!(
206211
"__rust_dir_structure_temp_{}_{}",
207-
std::process::id(),
208-
FS_TEMP_DIR_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst)
212+
process::id(),
213+
FS_TEMP_DIR_ID.fetch_add(1, Ordering::SeqCst)
209214
))
210215
}
211216
}

src/dev/dir-structure/src/vfs/tokio_fs_vfs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ mod imp {
520520
mod atomic_dir_imp {
521521
//! The [`VfsSupportsTemporaryDirectoriesAsync`] implementation for the [`TokioFsVfs`] file system.
522522
523+
use tokio::fs;
524+
523525
use super::*;
524526
use crate::atomic_dir::TempDirApiAsync;
525527
use crate::atomic_dir::VfsSupportsTemporaryDirectoriesAsync;
@@ -549,7 +551,7 @@ mod atomic_dir_imp {
549551
) -> Self::FuturePersistAt {
550552
Box::pin(async move {
551553
vfs.create_parent_dir(path.clone()).await?;
552-
tokio::fs::rename(&self.0, &path)
554+
fs::rename(&self.0, &path)
553555
.await
554556
.map_err(|e| Error::Io(path.clone(), e))?;
555557
Ok(())

0 commit comments

Comments
 (0)