Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
git_borg_linker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LBMC
Hub
git_borg_linker
Commits
8166c524
Verified
Commit
8166c524
authored
2 years ago
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
src/clean.rs: add clean module
parent
b7da81e2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/clean.rs
+31
-0
31 additions, 0 deletions
src/clean.rs
with
31 additions
and
0 deletions
src/clean.rs
0 → 100644
+
31
−
0
View file @
8166c524
use
crate
::
commit
;
use
colored
::
Colorize
;
use
std
::{
path
::
PathBuf
,
process
::
exit
};
/// Get the path of the .tmp folder
///
/// # Description
/// Get the path of the .tmp folder at the root of the project folder but don't
/// create it
pub
(
crate
)
fn
get_tmp_path
(
borgfolder
:
&
PathBuf
)
->
PathBuf
{
let
mut
tmp_folder
=
borgfolder
.parent
()
.unwrap
()
.to_path_buf
();
tmp_folder
.push
(
".tmp"
);
tmp_folder
}
/// Function used to remove the .tmp repository
pub
fn
clean
()
{
let
(
borg_folder
,
_
)
=
commit
::
check_path
();
let
tmp_folder
=
get_tmp_path
(
&
borg_folder
);
if
!
tmp_folder
.is_dir
()
{
println!
(
"{}: The .tmp folder doesn't exits !"
,
"info"
.blue
());
return
();
}
match
std
::
fs
::
remove_dir_all
(
&
tmp_folder
)
{
Ok
(
_
)
=>
(),
Err
(
e
)
=>
{
eprintln!
(
"{}: Unable to remove .tmp directory. {}"
,
"error"
.red
(),
e
);
exit
(
1
);
}
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment