Skip to content

Commit

Permalink
fix issue where photodatabase files were being overwritten
Browse files Browse the repository at this point in the history
fixes #7
  • Loading branch information
raleighlittles committed Sep 21, 2024
1 parent 097b5ff commit 7588b32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 2 additions & 8 deletions parser/src/helpers/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,10 @@ const MAC_TO_LINUX_EPOCH_CONVERSION: i64 = 2082844800;

/// Converts a given Mac epoch time into an actual UTC timestamp
pub fn get_timestamp_as_mac(mac_timestamp: u64) -> chrono::DateTime<chrono::Utc> {
return chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(
chrono::NaiveDateTime::from_timestamp_opt(
(mac_timestamp as i64) - MAC_TO_LINUX_EPOCH_CONVERSION,
0,
)
.unwrap(),
chrono::offset::Utc,
);
return chrono::DateTime::<chrono::Utc>::from_timestamp((mac_timestamp as i64) - MAC_TO_LINUX_EPOCH_CONVERSION, 0).unwrap();
}


/// Converts an integer seconds into a string representing that time in hours, minutes, and seconds
/// only showing the time units appropriately (ie not showing "hours" if the time is less than 1 hour)
/// and with correct pluralization (ie "1 second" vs "2 seconds")
Expand Down
5 changes: 4 additions & 1 deletion parser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fn main() {

let mut itunesdb_file_as_bytes = Vec::new();

// https://stackoverflow.com/questions/47660946/why-does-a-file-need-to-be-mutable-to-call-readread-to-string
let mut itunesdb_file = std::fs::File::open(itunesdb_file_path).unwrap();

itunesdb_file.read_to_end(&mut itunesdb_file_as_bytes).unwrap();
Expand All @@ -63,7 +64,9 @@ fn main() {
.nth(2)
.expect("Missing second parameter: iTunes DB file type. Supported types are 'photo', 'itunes', 'itprefs', 'playcounts', 'pfalbumbs', and 'preferences'");

let desired_report_csv_filename = itunesdb_filename.to_string();
let desired_report_csv_filename = itunesdb_filename.to_string() + ".csv";

assert!(desired_report_csv_filename != itunesdb_filename);

if itunesdb_file_type == "photo" {
let photos_csv_writer = helpers::helpers::init_csv_writer(&desired_report_csv_filename);
Expand Down

0 comments on commit 7588b32

Please sign in to comment.