From e4cf88f88f808a3fc229a8b97f3e2c524cb556dc Mon Sep 17 00:00:00 2001 From: kolena Date: Sun, 7 Oct 2018 15:40:09 +0200 Subject: [PATCH] Using u64 as file/file version ID --- src/dao.rs | 8 ++++---- src/lib.rs | 6 +++--- src/server.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/dao.rs b/src/dao.rs index 4aed17a..845e063 100644 --- a/src/dao.rs +++ b/src/dao.rs @@ -208,7 +208,7 @@ impl Dao { } } - pub fn get_hash_size_and_storage_name(&self, version_id: u32) -> mysql::error::Result> { + pub fn get_hash_size_and_storage_name(&self, version_id: u64) -> mysql::error::Result> { let stopwatch = Stopwatch::start_new(); self.pool.prep_exec(format!("select hash, size, storage_name from `{}`.files_versions where id=:version_id", self.db_name), @@ -224,7 +224,7 @@ impl Dao { }) } - pub fn get_storage_names(&self, device_id: &str, file_id: u32) -> mysql::error::Result> { + pub fn get_storage_names(&self, device_id: &str, file_id: u64) -> mysql::error::Result> { let stopwatch = Stopwatch::start_new(); self.pool.prep_exec(format!("select storage_name from `{}`.files_versions join `{}`.files on `{}`.files_versions.file_id=`{}`.files.id where `{}`.files.id=:file_id and `{}`.files.device_id=:device_id", self.db_name, self.db_name, self.db_name, self.db_name, self.db_name, self.db_name), @@ -283,7 +283,7 @@ impl Dao { }) } - pub fn remove_file_version(&self, version_id: u32) -> mysql::error::Result> { + pub fn remove_file_version(&self, version_id: u64) -> mysql::error::Result> { debug!(self.logger, "Deleting file version with"; "id" => version_id); self.get_hash_size_and_storage_name(version_id) @@ -302,7 +302,7 @@ impl Dao { }) } - pub fn remove_file(&self, device_id: &str, file_id: u32) -> Result>, Error> { + pub fn remove_file(&self, device_id: &str, file_id: u64) -> Result>, Error> { debug!(self.logger, "Deleting file versions"; "file_id" => file_id, "device_id" => device_id); self.get_storage_names(device_id, file_id) diff --git a/src/lib.rs b/src/lib.rs index 60f4994..44a028f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -248,7 +248,7 @@ pub fn save(logger: &Logger, statsd_client: StatsdClient, repo: &Repo, dao: &Dao }) } -pub fn load(logger: Logger, repo: &Repo, dao: &Dao, version_id: u32) -> Result)>, Error> { +pub fn load(logger: Logger, repo: &Repo, dao: &Dao, version_id: u64) -> Result)>, Error> { dao.get_hash_size_and_storage_name(version_id) .map(|n| { n.map(|(hash, size, storage_name)| { @@ -287,7 +287,7 @@ pub fn list_devices(dao: &Dao, account_id: &str) -> Result Result { +pub fn remove_file_version(repo: &Repo, dao: &Dao, version_id: u64) -> Result { dao.remove_file_version(version_id) .map_err(Error::from) .map(|opt| opt.map(|sn| repo.repo.rm(&sn).map_err(Error::from))) @@ -298,7 +298,7 @@ pub fn remove_file_version(repo: &Repo, dao: &Dao, version_id: u32) -> Result Result { +pub fn remove_file(repo: &Repo, dao: &Dao, device_id: &str, file_id: u64) -> Result { dao.remove_file(device_id, file_id) .map(|opt| match opt { Some(storage_names) => { diff --git a/src/server.rs b/src/server.rs index 527036f..f4ba7f4 100644 --- a/src/server.rs +++ b/src/server.rs @@ -26,12 +26,12 @@ struct UploadMetadata { #[derive(FromForm)] struct DownloadMetadata { - file_version_id: u32, + file_version_id: u64, } #[derive(FromForm)] struct RemoveFileMetadata { - file_id: u32, + file_id: u64, } #[derive(FromForm)] @@ -41,7 +41,7 @@ struct ListFilesMetadata { #[derive(FromForm)] struct RemoveFileVersionMetadata { - file_version_id: u32, + file_version_id: u64, } #[derive(FromForm)]