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).
此服务用于使 USB 与主服务器同步( 基本上像 Drobox 一样, 但只有下载和同步文件夹在可移动媒体上 ) 。 归档可以长到几千兆字节。 大约 1GB 文件每周更新大约400个用户的密钥 。
由于整个更新过程对用户是透明的,因此在数据写入归档时,他们“em>unplut USB(即使我用某种叫喊、闪烁的警告:
因此基本上我需要归档的书写 transacted 。 如果他们失败了, 只要他们不将容器置于不一致的状态。 要么文件是完全写好的, 要么是“ em> not em” 。 如果文件是部分写好的, 如果容器实际上不“ 看见”, 则文件是肯定的 。
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?
这是我至今为止得到的:
- 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.
如果这个问题过于笼统,请将其移至SU或其它地方。