handle fs metadata.created() not present
This commit is contained in:
@@ -13,18 +13,19 @@ COPY frontend/ ./
|
||||
RUN npm run generate
|
||||
|
||||
|
||||
FROM rust:bookworm AS backend-builder
|
||||
FROM rust:alpine AS backend-builder
|
||||
WORKDIR /usr/src/warren
|
||||
|
||||
COPY backend/Cargo.toml backend/Cargo.lock ./
|
||||
RUN mkdir -p src/bin/backend && mkdir src/lib && echo "fn main() {}" > src/bin/backend/main.rs && echo "" > src/lib/lib.rs
|
||||
RUN apk add --no-cache pkgconfig openssl-dev libc-dev
|
||||
RUN cargo build --release
|
||||
COPY backend/ .
|
||||
RUN touch src/bin/backend/main.rs && touch src/lib/lib.rs
|
||||
RUN cargo build --release
|
||||
|
||||
|
||||
FROM debian:bookworm
|
||||
FROM alpine:3
|
||||
WORKDIR /var/lib/warren
|
||||
|
||||
COPY --from=backend-builder /usr/src/warren/target/release/warren_backend /usr/bin/warren
|
||||
|
||||
@@ -12,7 +12,7 @@ pub struct File {
|
||||
name: FileName,
|
||||
file_type: FileType,
|
||||
mime_type: Option<FileMimeType>,
|
||||
created_at: u64,
|
||||
created_at: Option<u64>,
|
||||
}
|
||||
|
||||
impl File {
|
||||
@@ -20,7 +20,7 @@ impl File {
|
||||
name: FileName,
|
||||
file_type: FileType,
|
||||
mime_type: Option<FileMimeType>,
|
||||
created_at: u64,
|
||||
created_at: Option<u64>,
|
||||
) -> Self {
|
||||
Self {
|
||||
name,
|
||||
@@ -42,7 +42,7 @@ impl File {
|
||||
self.mime_type.as_ref()
|
||||
}
|
||||
|
||||
pub fn created_at(&self) -> u64 {
|
||||
pub fn created_at(&self) -> Option<u64> {
|
||||
self.created_at
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ pub struct WarrenFileElement {
|
||||
name: String,
|
||||
file_type: FileType,
|
||||
mime_type: Option<String>,
|
||||
created_at: u64,
|
||||
created_at: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
|
||||
@@ -73,7 +73,11 @@ impl FileSystem {
|
||||
}
|
||||
};
|
||||
let metadata = entry.metadata().await?;
|
||||
let created_at = metadata.created()?.duration_since(UNIX_EPOCH)?.as_secs();
|
||||
let created_at = metadata
|
||||
.created()
|
||||
.ok()
|
||||
.map(|c| c.duration_since(UNIX_EPOCH).ok().map(|c| c.as_secs()))
|
||||
.flatten();
|
||||
|
||||
let mime_type = match file_type {
|
||||
FileType::File => FileMimeType::from_name(&name),
|
||||
|
||||
@@ -59,6 +59,7 @@ async function openRenameDialog() {
|
||||
>
|
||||
<span>{{ entry.name }}</span>
|
||||
<NuxtTime
|
||||
v-if="entry.createdAt != null"
|
||||
:datetime="entry.createdAt * 1000"
|
||||
class="text-muted-foreground text-sm"
|
||||
relative
|
||||
|
||||
@@ -10,7 +10,7 @@ export type DirectoryEntry = {
|
||||
fileType: FileType;
|
||||
mimeType: string | null;
|
||||
/// Timestamp in seconds
|
||||
createdAt: number;
|
||||
createdAt: number | null;
|
||||
};
|
||||
|
||||
export type UploadStatus =
|
||||
|
||||
Reference in New Issue
Block a user