summaryrefslogtreecommitdiff
path: root/server/src/fs_utils.rs
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-02-01 22:42:11 +0100
committerJoel Klinghed <the_jk@spawned.biz>2025-02-01 22:42:11 +0100
commitd780391408b9e6d443e5e4f907748cae484b79fb (patch)
treed961efd62478248081d1a327c818d6fa171f0a2d /server/src/fs_utils.rs
parent05b674190f26e2a58cc7b7288586c031552d50f3 (diff)
Use workspace instead of features
Having to include --feature=build-server in basically all commands that wasn't building eyeballs-githook got tiring quickly. Instead, use workspaces, with a separate project for building the githook. It means I also had to add a library common with code shared by both githook and server.
Diffstat (limited to 'server/src/fs_utils.rs')
-rw-r--r--server/src/fs_utils.rs54
1 files changed, 0 insertions, 54 deletions
diff --git a/server/src/fs_utils.rs b/server/src/fs_utils.rs
deleted file mode 100644
index 7905d01..0000000
--- a/server/src/fs_utils.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-#![allow(dead_code)]
-
-use std::io;
-use std::path::Path;
-use tokio::fs;
-
-pub async fn create_dir_allow_existing(path: impl AsRef<Path>) -> io::Result<()> {
- match fs::create_dir(path).await {
- Ok(_) => Ok(()),
- Err(e) => {
- if e.kind() == io::ErrorKind::AlreadyExists {
- Ok(())
- } else {
- Err(e)
- }
- }
- }
-}
-
-pub async fn remove_file_allow_not_found(path: impl AsRef<Path>) -> io::Result<()> {
- match fs::remove_file(path).await {
- Ok(_) => Ok(()),
- Err(e) => {
- if e.kind() == io::ErrorKind::NotFound {
- Ok(())
- } else {
- Err(e)
- }
- }
- }
-}
-
-pub async fn symlink_update_existing(
- src: impl AsRef<Path>,
- dst: impl AsRef<Path>,
-) -> io::Result<()> {
- let src = src.as_ref();
- let dst = dst.as_ref();
- match fs::symlink(&src, &dst).await {
- Ok(_) => Ok(()),
- Err(e) => {
- if e.kind() == io::ErrorKind::AlreadyExists {
- let path = fs::read_link(&dst).await?;
- if path == src {
- return Ok(());
- }
- fs::remove_file(&dst).await?;
- fs::symlink(&src, &dst).await
- } else {
- Err(e)
- }
- }
- }
-}