Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion anni/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(try_blocks)]
#![allow(incomplete_features)]
#![feature(impl_trait_in_assoc_type)]

Expand Down
10 changes: 6 additions & 4 deletions anni/src/subcommands/workspace/fsck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ fn handle_workspace_fsck(me: WorkspaceFsckAction) -> anyhow::Result<()> {
let albums = workspace.scan()?;
for album in albums {
if let WorkspaceAlbumState::Dangling(album_path) = album.state {
let result: anyhow::Result<()> = try {
let result = || -> anyhow::Result<()> {
let dot_album = album_path.join(".album");
let real_path = workspace.controlled_album_path(&album.album_id, 2);
if !real_path.exists() {
fs::create_dir_all(&real_path)?;
}
fs::remove_file(&dot_album, false)?;
fs::symlink_dir(&real_path, &dot_album)?;
};
Ok(())
}();

if let Err(e) = result {
log::error!(
Expand All @@ -44,7 +45,7 @@ fn handle_workspace_fsck(me: WorkspaceFsckAction) -> anyhow::Result<()> {
let albums = workspace.scan()?;
for album in albums {
if let WorkspaceAlbumState::Garbage = album.state {
let result: anyhow::Result<()> = try {
let result = || -> anyhow::Result<()> {
if let Ok(real_path) = workspace.get_album_controlled_path(&album.album_id) {
// 1. remove garbage album directory
fs::remove_dir_all(&real_path, true)?;
Expand All @@ -63,7 +64,8 @@ fn handle_workspace_fsck(me: WorkspaceFsckAction) -> anyhow::Result<()> {
}
}
}
};
Ok(())
}();

if let Err(e) = result {
log::error!("Error while collecting garbage: {}", e);
Expand Down
Loading