leetcode-export icon indicating copy to clipboard operation
leetcode-export copied to clipboard

add support for incremental updates

Open charlie-curtis opened this issue 4 months ago • 0 comments

Incremental Backup Feature - Pull Request Summary

Overview

Added --checkpoint-file functionality to enable incremental backups, significantly reducing backup time for users who run the script regularly. This is an optional flag

Problem Solved

Previously, every run was a full backup, requiring downloading all submissions regardless of whether they had been processed before. This made regular backups slower than necessary.

Solution

The checkpoint feature stores the Unix timestamp of the newest processed submission. Subsequent runs only process submissions newer than the checkpoint, leveraging LeetCode's reverse chronological API ordering to stop early when reaching older submissions.

Key Features

  • Efficient: Stops API pagination early when reaching older submissions
  • Safe: Only updates checkpoint after successful completion of entire script to prevent over-checkpointing
  • User-friendly: Prompts for confirmation when creating new checkpoint files
  • Respects filters: Only updates checkpoint when submissions are actually written (honors --only-accepted, --language, etc.)

Usage

leetcode-export --checkpoint-file ~/.leetcode_checkpoint --only-accepted

Implementation Details

  • Stores Unix timestamps for timezone-agnostic operation
  • Updates checkpoint atomically at end of successful runs only
  • Maintains backward compatibility (optional feature)
  • Comprehensive error handling and logging

This feature makes regular LeetCode backups practical for active users while maintaining the robustness of the existing codebase.

charlie-curtis avatar Aug 04 '25 03:08 charlie-curtis