AIXLOGIS 로고AIXLOGIS
Devlog

(Python_backup tool) Merging a Legacy Script Into the Main App — Using Hash Comparison to Avoid Unnecessary Overwrites

#Python#Automation#Refactoring

Overview

There was a small, separate sync script that had long been used independently in the same internal environment. Its job was to copy a specific office macro file from network storage to a designated path on the user's PC. Since users had to run two separate programs every time, we merged it into the main backup tool.

Why We Chose This

  • Merging two programs into one meant we no longer had to maintain duplicate connection info and connection logic across both.
  • The old script relied on plain console print output; folding it into the main app's logging system made it much easier to trace the cause when something goes wrong.

Key Implementation Points

1. Deciding whether to copy based on file hash

Instead of always overwriting unconditionally, we now compare the hash of the source and destination files and only copy when the content has actually changed. When the contents match, we skip the copy entirely, cutting down on unnecessary disk writes and file-lock conflicts.

sync(source, destination):
    source_hash = compute_hash(source)
    destination_hash = compute_hash(destination) if it exists, else None

    if source_hash == destination_hash:
        skip
    else:
        copy(source → destination)
    result = (success, message)
    return result

2. Auto-connect and auto-sync on app startup

If connection info is already saved, the app now automatically attempts to connect the moment it launches, with no click required, and immediately proceeds to sync the macro file once connected. The goal was to give users the experience of "just leave the program open and it stays up to date on its own."

3. Expanding what gets saved in settings

We extended the existing connection-info storage structure to also save the sync target path and filename, so once configured, it's reused automatically on every subsequent launch without re-entry.

Retrospective

  • When absorbing a standalone script into the main app, reworking it to match the main app's existing logging and settings-storage conventions — rather than porting it over as-is — paid off significantly in later maintainability.
  • The "only copy what actually changed" pattern via hash comparison became a default principle we've since reused for similar sync features.
#Python#Automation#Refactoring

More Related Insights

DEV
Devlog

(Python_backup tool) What Adding a 'Download' Feature to the Backup Tool Taught Us About Direction-Agnostic Design

DEV
Devlog

(Python_backup tool) Adding User Control Over the Auto-Sync Feature

News

Construction Robotics Startup Gritt Secures $32M to Automate Solar Plant Construction