mirror of
https://github.com/readur/readur.git
synced 2026-05-07 23:10:12 -05:00
92b21350db
✅ Core Optimizations Implemented 1. 📊 New Database Schema: Added webdav_directories table to track directory ETags, file counts, and metadata 2. 🔍 Smart Directory Checking: Before deep scans, check directory ETags with lightweight Depth: 0 PROPFIND requests 3. ⚡ Skip Unchanged Directories: If directory ETag matches, skip the entire deep scan 4. 🗂️ N-Depth Subdirectory Tracking: Recursively track all subdirectories found during scans 5. 🎯 Individual Subdirectory Checks: When parent unchanged, check each known subdirectory individually 🚀 Performance Benefits Before: Every sync = Full Depth: infinity scan of entire directory treeAfter: - First sync: Full scan + directory tracking setup - Subsequent syncs: Quick ETag checks → skip unchanged directories entirely - Changed directories: Only scan the specific changed subdirectories 📁 How It Works 1. Initial Request: PROPFIND Depth: 0 on /Documents → get directory ETag 2. Database Check: Compare with stored ETag for /Documents 3. If Unchanged: Check each known subdirectory (/Documents/2024, /Documents/Archive) individually 4. If Changed: Full recursive scan + update all directory tracking data
22 lines
1.0 KiB
SQL
22 lines
1.0 KiB
SQL
-- Add directory-level ETag tracking for efficient WebDAV sync
|
|
-- This optimization allows skipping unchanged directories entirely
|
|
|
|
CREATE TABLE IF NOT EXISTS webdav_directories (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
|
|
directory_path TEXT NOT NULL,
|
|
directory_etag TEXT NOT NULL,
|
|
last_scanned_at TIMESTAMPTZ DEFAULT NOW(),
|
|
file_count BIGINT DEFAULT 0,
|
|
total_size_bytes BIGINT DEFAULT 0,
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
|
|
|
UNIQUE(user_id, directory_path)
|
|
);
|
|
|
|
-- Create indexes for performance
|
|
CREATE INDEX IF NOT EXISTS idx_webdav_directories_user_id ON webdav_directories(user_id);
|
|
CREATE INDEX IF NOT EXISTS idx_webdav_directories_path ON webdav_directories(user_id, directory_path);
|
|
CREATE INDEX IF NOT EXISTS idx_webdav_directories_etag ON webdav_directories(directory_etag);
|
|
CREATE INDEX IF NOT EXISTS idx_webdav_directories_last_scanned ON webdav_directories(last_scanned_at); |