Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7985705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:37:53+00:00 2026-06-04T11:37:53+00:00

I’m creating a Windows service that runs when a specific USB key is plugged

  • 0

I’m creating a Windows service that runs when a specific USB key is plugged in.
What it does is simple: contact an FTP server, download some files, and store
them in an (encrypted) archive on the USB. The archive can be opened read-only
with a tool provided to the client (but that’s irrelevant to my problem).

The service is used to keep the USB in sync with the master server (pretty much like Dropbox, but only download and the synchronized folders are on the removable media). The archive can grow up to a few gigabytes. About 1GB of the files are updated every week on the keys of around 400 users.

Since the entire update process is transparent to the user, there is the non-negligible chance that they unplug the USB when data is being written to the archive (even if I put some kind of screaming, flashy warning: DO NOT UNPLUG). Corrupting the archive would require to download it again in its entirety, that means quite a lot of bandwidth wasted on the already loaded servers.

So basically I need the writes to the archive to be transacted. It’s OK if they fail, as long as they do not put the container in an inconsistent state. Either the file is entirely written, either it is not. It’s OK if the file is partially written if the container does not actually “see” it.

The question is here:
How can I guarantee data consistency at all times? Specifically, how do you make IO operations to work as transactions? What would you suggest? Shall I implement something on my own? Or are there already containers that offer this functionnality?

This is what I’ve got so far:

  • Create a new archive, rename on commit: not possible, the archive is too large.
  • Zip / Tar / 7z: unsuitable, a failed write will corrupt the archive
  • Truecrypt: unsuitable, as it requires a file system driver (Administrator privileges that the users dot not have).
  • Anything that requires mapping a file system to a file: unsuitable, pretty sure you can’t do that without being Administrator, but if it’s possible, it’d be great.
  • Storing files in a SQLite DB: it’s ACID so that could indeed be a solution. However, it would require splitting the files as SQLite has a limited BLOB capacity. Not very elegant, but I’m ready to go that way. Also SQLite’s transaction journal can get pretty large when storing large blobs.
  • Implement that on my own: I’d rather avoid that as much as possible but I’m not afraid to do it. I just find the topic pretty complex.

If this question is too general please move it to SU or something.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:37:54+00:00Added an answer on June 4, 2026 at 11:37 am

    You may want to try using something like svn or git to download encrypted differences; they typically can be used to reconstruct a file locally if it gets corrupted. Or just download diffs and use patch to generate the latest file version.

    You have other problems if the user unplugs a FLASH drive while it’s in the process of writing data. Many are not reliable (at the flash block level, not the file system level) and can be corrupted to the point that a journaling file system like NTFS or EXT3 cannot recover. There’s more detail here: https://superuser.com/questions/290060/can-flash-memory-be-physically-damaged-if-power-is-interrupted-while-writing

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.