Skip to content

Commit 47cef13

Browse files
committed
fix(scanner): scan more book types, not just epub
1 parent 3c5d8df commit 47cef13

2 files changed

Lines changed: 66 additions & 3 deletions

File tree

scripts/install.sh

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ EOF
273273

274274
setup_media_permissions() {
275275
local media_dirs=$1
276+
local needs_reload=false
276277

277278
print_info "Setting up media directory permissions..."
278279

@@ -293,13 +294,13 @@ setup_media_permissions() {
293294
# Fall back to adding dust user to the directory owner's group
294295
local dir_owner=$(stat -c '%U' "$dir")
295296
local dir_group=$(stat -c '%G' "$dir")
296-
usermod -aG "$dir_group" "$SERVICE_USER" 2>/dev/null || true
297+
usermod -aG "$dir_group" "$SERVICE_USER" 2>/dev/null && needs_reload=true || true
297298
}
298299
else
299300
print_info "Adding group permissions for $dir"
300301
# No setfacl, use group permissions
301302
local dir_group=$(stat -c '%G' "$dir")
302-
usermod -aG "$dir_group" "$SERVICE_USER" 2>/dev/null || {
303+
usermod -aG "$dir_group" "$SERVICE_USER" 2>/dev/null && needs_reload=true || {
303304
print_warning "Could not add $SERVICE_USER to group $dir_group"
304305
print_warning "You may need to manually grant access to $dir"
305306
}
@@ -312,6 +313,52 @@ setup_media_permissions() {
312313
done
313314

314315
print_info "Media directory permissions configured"
316+
317+
# If we added the user to groups, we need to reload systemd
318+
if [ "$needs_reload" = true ]; then
319+
echo ""
320+
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
321+
echo -e "${YELLOW} Important: Group Changes Detected${NC}"
322+
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
323+
echo ""
324+
echo "The 'dust' user was added to one or more groups to access your media."
325+
echo "For these changes to take effect, the systemd daemon needs to reload"
326+
echo "and the service needs to restart."
327+
echo ""
328+
329+
if [ -t 0 ]; then
330+
# Interactive mode - ask user
331+
read -p "Would you like to reload systemd and restart the service now? [Y/n] " -n 1 -r
332+
echo ""
333+
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
334+
print_info "Reloading systemd daemon..."
335+
systemctl daemon-reload
336+
if systemctl is-active --quiet "$SERVICE_NAME" 2>/dev/null; then
337+
print_info "Restarting service to apply group changes..."
338+
systemctl restart "$SERVICE_NAME"
339+
sleep 2
340+
if systemctl is-active --quiet "$SERVICE_NAME"; then
341+
print_success "Service restarted successfully"
342+
else
343+
print_warning "Service may not have restarted properly"
344+
print_info "Check logs with: journalctl -u $SERVICE_NAME -n 50"
345+
fi
346+
fi
347+
else
348+
print_warning "Skipping reload. To apply changes later, run:"
349+
print_info " sudo systemctl daemon-reload"
350+
print_info " sudo systemctl restart $SERVICE_NAME"
351+
fi
352+
else
353+
# Non-interactive mode - just inform the user
354+
print_warning "Running in non-interactive mode."
355+
print_info "To apply group changes, please run:"
356+
print_info " sudo systemctl daemon-reload"
357+
print_info " sudo systemctl restart $SERVICE_NAME"
358+
fi
359+
echo ""
360+
fi
361+
315362
print_info "Note: If you still see permission errors, you may need to:"
316363
print_info " sudo chmod -R +rX /path/to/media"
317364
print_info " Or: sudo chown -R $SERVICE_USER:$SERVICE_USER /path/to/media"

src/modules/books/background_tasks.zig

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,23 @@ fn scanDirectory(ctx: *BackgroundTaskContext, dir_path: []const u8) !void {
4545
while (try walker.next()) |entry| {
4646
if (entry.kind != .file) continue;
4747

48-
if (std.mem.endsWith(u8, entry.basename, ".epub")) {
48+
// Check for supported ebook formats
49+
const is_ebook = std.mem.endsWith(u8, entry.basename, ".epub") or
50+
std.mem.endsWith(u8, entry.basename, ".pdf") or
51+
std.mem.endsWith(u8, entry.basename, ".mobi") or
52+
std.mem.endsWith(u8, entry.basename, ".azw") or
53+
std.mem.endsWith(u8, entry.basename, ".azw3") or
54+
std.mem.endsWith(u8, entry.basename, ".cbz") or
55+
std.mem.endsWith(u8, entry.basename, ".cbr") or
56+
std.mem.endsWith(u8, entry.basename, ".djvu") or
57+
// Uppercase variants
58+
std.mem.endsWith(u8, entry.basename, ".EPUB") or
59+
std.mem.endsWith(u8, entry.basename, ".PDF") or
60+
std.mem.endsWith(u8, entry.basename, ".MOBI") or
61+
std.mem.endsWith(u8, entry.basename, ".CBZ") or
62+
std.mem.endsWith(u8, entry.basename, ".CBR");
63+
64+
if (is_ebook) {
4965
const full_path = try std.fs.path.join(ctx.allocator, &.{ dir_path, entry.path });
5066
defer ctx.allocator.free(full_path);
5167

0 commit comments

Comments
 (0)