Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dd38431
Showing
10 changed files
with
776 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "file_checker" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Jetbrains Lock Checker | ||
|
||
When shutting down a Linux machine without exiting a Jetbrains editor correctly, residual `.lock` files can prevent the | ||
editor from starting again *(See this [StackOverflow post](https://stackoverflow.com/questions/77003028/error-while-opening-intellij-idea-due-to-an-already-running-process))*. | ||
|
||
This program deletes those `.lock` files. | ||
|
||
*You should not need this. Just shutdown your editors correctly* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::path::Path; | ||
|
||
use std::process::exit; | ||
use std::{env, fs}; | ||
|
||
fn main() { | ||
// get home dir from $HOME env variable and construct config folder string | ||
let home_key = "HOME"; | ||
let home_dir = env::var(home_key).expect("$HOME variable not set"); | ||
let config_dir = format!("{}/.config/JetBrains", home_dir); | ||
|
||
// make sure the path exists | ||
if !Path::new(&config_dir).exists() { | ||
println!("JetBrains config folder doesn't exist"); | ||
exit(1); | ||
} | ||
|
||
// get paths in config folder | ||
let paths = fs::read_dir(&config_dir).unwrap(); | ||
|
||
let mut got_error = false; | ||
|
||
for path in paths { | ||
let p = path.unwrap(); | ||
|
||
if p.file_type().unwrap().is_dir() { | ||
let lock_path = format!("{}/.lock", p.path().display()); | ||
|
||
// try to delete the lock file, if an error occurs that's not the file not found error, print it out | ||
match fs::remove_file(&lock_path) { | ||
Ok(_) => {} | ||
Err(e) => { | ||
if e.kind().to_string() != "entity not found" { | ||
println!("{}", e); | ||
got_error = true; | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
|
||
if got_error { | ||
exit(1) | ||
} | ||
} |