aboutsummaryrefslogtreecommitdiffstats
path: root/src/migration_handler.rs
diff options
context:
space:
mode:
authorNathan Jaremko2019-02-24 16:52:01 -0500
committerNathan Jaremko2019-02-24 17:53:19 -0500
commit22e617eec8e2d8da36788ae40fb53c2ed2ebe734 (patch)
tree99ecbf8a7df65c9748b73debf9ece08ad9858315 /src/migration_handler.rs
parente54af75fa1fe7f5e9da3bd858058ab491efea77a (diff)
downloadpodcast-22e617eec8e2d8da36788ae40fb53c2ed2ebe734.tar.bz2
Improve code0.8.0
Diffstat (limited to 'src/migration_handler.rs')
-rw-r--r--src/migration_handler.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/migration_handler.rs b/src/migration_handler.rs
new file mode 100644
index 0000000..73a0241
--- /dev/null
+++ b/src/migration_handler.rs
@@ -0,0 +1,16 @@
+use crate::errors::*;
+use crate::utils::*;
+use std::fs;
+
+pub fn migrate_old_subscriptions() -> Result<()> {
+ let path = get_podcast_dir()?;
+ let mut old_path = path.clone();
+ old_path.push(".subscriptions");
+ if old_path.exists() {
+ println!("Migrating old subscriptions file...");
+ let new_path = get_sub_file()?;
+ fs::rename(&old_path, &new_path)
+ .chain_err(|| format!("Unable to move {:?} to {:?}", &old_path, &new_path))?;
+ }
+ Ok(())
+}