mirror of
https://github.com/agersant/polaris
synced 2024-11-10 02:04:13 +00:00
Fixed a bug where all music sources would be deleted when trying to add sources with duplicate names
This commit is contained in:
parent
96d702b79e
commit
f3abb816ff
1 changed files with 10 additions and 5 deletions
|
@ -103,12 +103,17 @@ impl Manager {
|
|||
}
|
||||
|
||||
pub fn set_mount_dirs(&self, mount_dirs: &[MountDir]) -> Result<()> {
|
||||
use self::mount_points::dsl::*;
|
||||
let mut connection = self.db.connect()?;
|
||||
diesel::delete(mount_points).execute(&mut connection)?;
|
||||
diesel::insert_into(mount_points)
|
||||
.values(mount_dirs)
|
||||
.execute(&mut *connection)?; // TODO https://github.com/diesel-rs/diesel/issues/1822
|
||||
connection
|
||||
.transaction::<_, diesel::result::Error, _>(|connection| {
|
||||
use self::mount_points::dsl::*;
|
||||
diesel::delete(mount_points).execute(&mut *connection)?;
|
||||
diesel::insert_into(mount_points)
|
||||
.values(mount_dirs)
|
||||
.execute(&mut *connection)?; // TODO https://github.com/diesel-rs/diesel/issues/1822
|
||||
Ok(())
|
||||
})
|
||||
.map_err(anyhow::Error::new)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue