mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Use relative track paths
This commit is contained in:
parent
a91eb178c7
commit
0abfad07f8
1 changed files with 6 additions and 6 deletions
|
|
@ -7,6 +7,7 @@ use gtk::prelude::*;
|
||||||
use gtk_macros::get_widget;
|
use gtk_macros::get_widget;
|
||||||
use musicus_backend::db::Medium;
|
use musicus_backend::db::Medium;
|
||||||
use musicus_backend::import::{ImportSession, State};
|
use musicus_backend::import::{ImportSession, State};
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
@ -160,9 +161,9 @@ impl MediumPreview {
|
||||||
async fn import(&self) -> Result<()> {
|
async fn import(&self) -> Result<()> {
|
||||||
// Create a new directory in the music library path for the imported medium.
|
// Create a new directory in the music library path for the imported medium.
|
||||||
|
|
||||||
let mut path = self.handle.backend.get_music_library_path().unwrap().clone();
|
let music_library_path = self.handle.backend.get_music_library_path().unwrap();
|
||||||
path.push(&self.medium.name);
|
let directory = PathBuf::from(&self.medium.name);
|
||||||
std::fs::create_dir(&path)?;
|
std::fs::create_dir(&music_library_path.join(&directory))?;
|
||||||
|
|
||||||
// Copy the tracks to the music library.
|
// Copy the tracks to the music library.
|
||||||
|
|
||||||
|
|
@ -175,12 +176,11 @@ impl MediumPreview {
|
||||||
// Set the track path to the new audio file location.
|
// Set the track path to the new audio file location.
|
||||||
|
|
||||||
let import_track = &import_tracks[index];
|
let import_track = &import_tracks[index];
|
||||||
let mut track_path = path.clone();
|
let track_path = directory.join(import_track.path.file_name().unwrap());
|
||||||
track_path.push(import_track.path.file_name().unwrap());
|
|
||||||
track.path = track_path.to_str().unwrap().to_owned();
|
track.path = track_path.to_str().unwrap().to_owned();
|
||||||
|
|
||||||
// Copy the corresponding audio file to the music library.
|
// Copy the corresponding audio file to the music library.
|
||||||
std::fs::copy(&import_track.path, &track_path)?;
|
std::fs::copy(&import_track.path, &music_library_path.join(&track_path))?;
|
||||||
|
|
||||||
tracks.push(track);
|
tracks.push(track);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue