From cdfda96dfaa4c90394c3ddf2e2c5d3c2cf0ebf33 Mon Sep 17 00:00:00 2001 From: Jonson Petard <41122242+greenhat616@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:24:47 +0800 Subject: [PATCH] chore: up --- src/linux.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/linux.rs b/src/linux.rs index d785f62..90665b6 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -1,8 +1,5 @@ -use crate::AutoLaunch; -use crate::Result; -use std::fs; -use std::io::Write; -use std::path::PathBuf; +use crate::{AutoLaunch, Result}; +use std::{fs, io::Write, path::PathBuf}; /// Linux implement impl AutoLaunch { @@ -47,7 +44,13 @@ impl AutoLaunch { let dir = get_dir(); if !dir.exists() { - fs::create_dir(&dir)?; + fs::create_dir_all(&dir).or_else(|e| { + if e.kind() == std::io::ErrorKind::AlreadyExists { + Ok(()) + } else { + Err(e) + } + })?; } let mut file = fs::OpenOptions::new() .write(true)