From fc07e282018b11570f5a7aa1834869ea93b93362 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 1 Apr 2014 21:23:03 -0400 Subject: [PATCH] library: Don't save length strings to disk Recalculating this doesn't change the runtime significantly, so we might as well save some disk space. Signed-off-by: Anna Schumaker --- lib/library.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/library.cpp b/lib/library.cpp index d2275f7a..440557e5 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -218,22 +218,33 @@ const std::string library :: Track :: primary_key() void library :: Track :: read(File &f) { + std::stringstream ss; + unsigned int minutes, seconds; + f >> library_id >> artist_id >> album_id >> genre_id; f >> track >> last_year >> last_month >> last_day; f >> play_count >> length; - length_str = f.getline(); title = f.getline(); filepath = f.getline(); + title_lower = filter :: lowercase(title); full_path = library_db.at(library_id)->root_path + "/" + filepath; library_db.at(library_id)->size++; + + minutes = length / 60; + seconds = length % 60; + ss << minutes << ":"; + if (seconds < 10) + ss << "0"; + ss << seconds; + length_str = ss.str(); } void library :: Track :: write(File &f) { f << library_id << " " << artist_id << " " << album_id << " " << genre_id; f << " " << track << " " << last_year << " " << last_month << " " << last_day; - f << " " << play_count << " " << length << " " << length_str << std :: endl; + f << " " << play_count << " " << length; // << std :: endl; f << title << std :: endl; f << filepath; }