Compare commits

..

2 Commits

Author SHA1 Message Date
d415f02e9f Added more todos 2025-10-18 15:21:36 -04:00
102732974d Added todos 2025-10-18 14:51:07 -04:00
7 changed files with 43 additions and 86 deletions

View File

@@ -4,7 +4,6 @@ on:
pull_request:
branches:
- main
- next-v0.8
jobs:
release:
@@ -26,15 +25,12 @@ jobs:
run: |
VERSION=$(grep '^version = "' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
BRANCH_REF="${{ gitea.ref }}"
BRANCH_REF="${GITHUB_REF}"
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH-111"
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE"
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH"
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-111"
echo "Version: $VERSION"
echo "Hash: $PROJECT_COMMIT_HASH"
echo "Branh ref: $BRANCH_REF"
echo "Branch: $BRANCH_NAME"
echo "Tag Release: $PROJECT_TAG_RELEASE"

View File

@@ -7,7 +7,6 @@ on:
pull_request:
branches:
- main
- next-v0.8
jobs:
check:

2
Cargo.lock generated
View File

@@ -149,7 +149,7 @@ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
[[package]]
name = "icarus_models"
version = "0.7.2"
version = "0.7.0"
dependencies = [
"josekit",
"rand",

View File

@@ -1,6 +1,6 @@
[package]
name = "icarus_models"
version = "0.7.2"
version = "0.7.0"
edition = "2024"
rust-version = "1.90"
description = "models used for the icarus project"

View File

@@ -7,22 +7,22 @@ pub struct CoverArt {
pub id: uuid::Uuid,
pub title: String,
#[serde(skip)]
pub directory: String,
pub filename: String,
pub path: String,
#[serde(skip)]
pub data: Vec<u8>,
pub song_id: uuid::Uuid,
}
pub mod init {
use super::CoverArt;
use crate::coverart::CoverArt;
/// Initializes the CoverArt with just the directory and filename
pub fn init_coverart_dir_and_filename(directory: &str, filename: &str) -> CoverArt {
pub fn init_coverart_only_path(path: String) -> CoverArt {
CoverArt {
directory: String::from(directory),
filename: String::from(filename),
..Default::default()
id: uuid::Uuid::nil(),
title: String::new(),
path: path.clone(),
data: Vec::new(),
song_id: uuid::Uuid::nil(),
}
}
}
@@ -30,12 +30,9 @@ pub mod init {
impl CoverArt {
/// Saves the coverart to the filesystem
pub fn save_to_filesystem(&self) -> Result<(), std::io::Error> {
match self.get_path() {
Ok(path) => match std::fs::File::create(&path) {
Ok(mut file) => match file.write_all(&self.data) {
Ok(_) => Ok(()),
Err(err) => Err(err),
},
match std::fs::File::create(&self.path) {
Ok(mut file) => match file.write_all(&self.data) {
Ok(_) => Ok(()),
Err(err) => Err(err),
},
Err(err) => Err(err),
@@ -44,46 +41,15 @@ impl CoverArt {
/// Removes the coverart from the filesystem
pub fn remove_from_filesystem(&self) -> Result<(), std::io::Error> {
match self.get_path() {
Ok(path) => {
let p = std::path::Path::new(&path);
if p.exists() {
match std::fs::remove_file(p) {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
} else {
Err(std::io::Error::other(
"Cannot delete file that does not exist",
))
}
let p = std::path::Path::new(&self.path);
if p.exists() {
match std::fs::remove_file(p) {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
Err(err) => Err(err),
}
}
/// Gets the path of the CoverArt
pub fn get_path(&self) -> Result<String, std::io::Error> {
if self.directory.is_empty() {
return Err(std::io::Error::other("Directory has not been initialized"));
} else if self.filename.is_empty() {
return Err(std::io::Error::other("Filename has not bee initialized"));
}
let directory = &self.directory;
let last_index = directory.len() - 1;
if let Some(character) = directory.chars().nth(last_index) {
let buffer = if character != '/' {
directory.clone() + "/"
} else {
directory.clone()
};
Ok(buffer + &self.filename.clone())
} else {
Err(std::io::Error::other(
"Could not access last character of directory",
"Cannot delete file that does not exist",
))
}
}
@@ -94,15 +60,11 @@ pub mod io {
/// Gets the raw data of the cover art
pub fn to_data(coverart: &super::CoverArt) -> Result<Vec<u8>, std::io::Error> {
match coverart.get_path() {
Ok(path) => {
let mut file = std::fs::File::open(path)?;
let mut buffer = Vec::new();
match file.read_to_end(&mut buffer) {
Ok(_) => Ok(buffer),
Err(err) => Err(err),
}
}
let path: &String = &coverart.path;
let mut file = std::fs::File::open(path)?;
let mut buffer = Vec::new();
match file.read_to_end(&mut buffer) {
Ok(_) => Ok(buffer),
Err(err) => Err(err),
}
}
@@ -114,11 +76,9 @@ mod tests {
#[test]
fn test_cover_art_image() {
let dir = String::from("./");
let filename = String::from("CoverArt.png");
let coverart = coverart::init::init_coverart_dir_and_filename(&dir, &filename);
let path: String = String::from("somepath");
let coverart = coverart::init::init_coverart_only_path(path.clone());
assert_eq!(dir, coverart.directory);
assert_eq!(filename, coverart.filename);
assert_eq!(path, coverart.path);
}
}

View File

@@ -39,8 +39,8 @@ pub struct Song {
pub track_count: i32,
#[serde(skip_serializing_if = "String::is_empty")]
pub audio_type: String,
#[serde(with = "time::serde::rfc3339::option")]
pub date_created: Option<time::OffsetDateTime>,
#[serde(skip_serializing_if = "String::is_empty")]
pub date_created: String,
#[serde(skip_serializing_if = "String::is_empty")]
pub filename: String,
#[serde(skip_serializing_if = "init::is_uuid_nil")]
@@ -71,22 +71,21 @@ impl Song {
pub fn song_path(&self) -> Result<String, std::io::Error> {
if self.directory.is_empty() {
return Err(std::io::Error::other("Directory has not been initialized"));
} else if self.filename.is_empty() {
return Err(std::io::Error::other("Filename has not bee initialized"));
return Err(std::io::Error::other("Directory does not exist"));
}
let directory = &self.directory;
let mut buffer: String = directory.clone();
let last_index = directory.len() - 1;
if let Some(character) = directory.chars().nth(last_index) {
let buffer: String = if character != '/' {
directory.clone() + "/"
} else {
directory.clone()
};
if character != '/' {
buffer += "/";
}
Ok(buffer + &self.filename.clone())
buffer += &self.filename.clone();
Ok(buffer)
} else {
Err(std::io::Error::other(
"Could not access last character of directory",

3
todos.txt Normal file
View File

@@ -0,0 +1,3 @@
// TODO: Make the functions/methods usable for checking if a token expires
// TODO: Separate directory and filename from path in coverart
// TODO: Change date type of song from string to date