function analyze_rm_filename_patterns
Analyzes and documents the rm-filename header patterns used in reMarkable cloud sync API requests by examining raw log data and printing a comprehensive report of file naming conventions, upload sequences, and implementation requirements.
/tf/active/vicechatdev/e-ink-llm/cloudtest/analyze_headers.py
10 - 76
simple
Purpose
This function serves as a documentation and analysis tool for understanding the reMarkable cloud sync protocol's file naming patterns. It identifies two main categories of files (Document UUID Files and System Files), documents their naming patterns, provides examples from actual logs, shows the correct upload sequence for syncing documents, and highlights common implementation issues. The function is primarily used for debugging, documentation, and ensuring correct implementation of the rm-filename header in upload operations.
Source Code
def analyze_rm_filename_patterns():
"""Analyze the rm-filename patterns from the raw logs"""
print("š reMarkable rm-filename Header Patterns Analysis")
print("=" * 60)
# Based on the raw logs from app_out_bis/Raw_07-29-2025-15-53-09.folder/
patterns = {
"Document UUID Files": {
"description": "Files associated with a specific document using its UUID",
"examples": [
"cf2a3833-4a8f-4004-ab8d-8dc3c5f561bc.metadata",
"cf2a3833-4a8f-4004-ab8d-8dc3c5f561bc.pagedata",
"cf2a3833-4a8f-4004-ab8d-8dc3c5f561bc.pdf",
"cf2a3833-4a8f-4004-ab8d-8dc3c5f561bc.content",
"cf2a3833-4a8f-4004-ab8d-8dc3c5f561bc.docSchema"
],
"pattern": "{document_uuid}.{extension}",
"usage": "Individual document components"
},
"System Files": {
"description": "Root-level system files without UUID",
"examples": [
"roothash",
"root.docSchema"
],
"pattern": "{system_name}[.extension]",
"usage": "Root directory updates and system schemas"
}
}
for category, info in patterns.items():
print(f"\nš {category}")
print(f" Description: {info['description']}")
print(f" Pattern: {info['pattern']}")
print(f" Usage: {info['usage']}")
print(" Examples:")
for example in info['examples']:
print(f" - rm-filename: {example}")
print(f"\nš§ Implementation Requirements:")
print("1. Document files MUST use the document UUID + extension")
print("2. Root/system files use fixed names without UUIDs")
print("3. ALL PUT requests must include rm-filename header")
print("4. Upload order matters (as seen in request sequence)")
print(f"\nš Upload Sequence (from logs):")
sequence = [
("26", "/sync/v4/root", "roothash", "Root directory listing"),
("28", "/sync/v3/files/...", "{uuid}.metadata", "Document metadata"),
("29", "/sync/v3/files/...", "{uuid}.pagedata", "Page data"),
("30", "/sync/v3/files/...", "{uuid}.content", "Document content"),
("30", "/sync/v3/files/...", "{uuid}.pdf", "PDF content"),
("31", "/sync/v3/files/...", "{uuid}.docSchema", "Document schema"),
("32", "/sync/v3/files/...", "root.docSchema", "Root schema"),
("33", "/sync/v3/root", "roothash", "Final root update")
]
for req_num, endpoint, rm_filename, description in sequence:
print(f" [{req_num}] {endpoint} -> rm-filename: {rm_filename} ({description})")
print(f"\nā ļø Current Issues in Upload Manager:")
print("1. Missing rm-filename for root/system updates")
print("2. Not following the correct upload sequence")
print("3. Some PUT calls don't include rm-filename at all")
return patterns
Return Value
Returns a dictionary containing two main categories ('Document UUID Files' and 'System Files'), where each category includes: 'description' (string explaining the file type), 'examples' (list of actual filenames from logs), 'pattern' (string template showing the naming convention), and 'usage' (string describing when these files are used). The dictionary structure mirrors the patterns analyzed from raw reMarkable sync logs.
Usage Example
# Run the analysis to understand rm-filename patterns
patterns = analyze_rm_filename_patterns()
# Output will print a comprehensive report to console
# Access the returned patterns dictionary
for category, info in patterns.items():
print(f"Category: {category}")
print(f"Pattern: {info['pattern']}")
print(f"Examples: {info['examples']}")
# Use the patterns to implement correct rm-filename headers
document_uuid = 'cf2a3833-4a8f-4004-ab8d-8dc3c5f561bc'
metadata_filename = f"{document_uuid}.metadata" # Following Document UUID Files pattern
root_filename = "roothash" # Following System Files pattern
Best Practices
- This function is primarily for analysis and documentation purposes, not for production use in upload operations
- The patterns returned should be used as a reference when implementing rm-filename headers in actual sync operations
- Pay attention to the upload sequence documented in the output, as order matters for successful syncing
- Document UUID files must always use the format {uuid}.{extension}, never omit the UUID
- System files like 'roothash' and 'root.docSchema' use fixed names without UUIDs
- All PUT requests to the reMarkable sync API must include the rm-filename header
- The function prints to stdout, so capture or redirect output if needed for logging purposes
- Use this analysis to verify that your upload manager implementation follows the correct patterns and sequence
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class RealAppUploadAnalyzer 67.1% similar
-
function generate_header_examples 65.8% similar
-
function analyze_pylontech_document 64.1% similar
-
function main_v113 63.6% similar
-
function main_v15 62.7% similar