FTP 站点的本地/远程访问同步

发布于 2024-10-06 05:15:15 字数 549 浏览 1 评论 0原文

我正在编写一些代码,通过根据也在 ftp 站点上的清单文件从 ftp 站点获取新的 dll 来更新应用程序,该清单文件指定了每个 dll 的版本。基本思想是,更新程序在启动时运行,它检查 ftp 站点上的清单,下载比应用程序当前使用的更新的任何 dll,然后启动应用程序并自行关闭。

这会导致以下问题,我不确定处理的最佳方法:假设我想在 ftp 站点上放置一个新的 dll,但同时更新程序应用程序实例尝试读取该 dll。如果我删除该 dll,然后复制新的,更新程序可能看不到该文件,即使清单表明该文件应该存在。

我有一种标记文件的想法,它将充当同步对象,并且我和更新程序实例可以将其存在用作锁,但这不仅仅是解决问题吗?在检查锁是否存在和创建锁之间仍然存在时间,在此期间其他人可以创建锁,并开始修改 ftp 文件。另外,如果某些更新程序在删除标记之前崩溃,则无法判断是否应删除剩余的标记。

编辑:我还看到建议将文件上传到另一个文件夹,然后重命名该文件夹,因为重命名应该是 ftp 中的原子操作,但是是否可以将文件夹重命名为现有文件夹的名称?难道不应该先删除现有的文件夹,从而导致同样的问题吗?

有标准方法来解决这个问题吗?

I am writing some code to update an application by fetching new dlls from an ftp site, according to a manifest file, also at the ftp site, which specifies the versions of each dll. The basic idea is, that an updater program runs at startup, which checks the manifest at the ftp site, downloads any dll's which are newer than those currently used by the application, and then starts the application and shuts itself down.

This leads to the following problem, that I am not sure of the best way to handle: Say that I want to put a new dll on the ftp site, but at the same time an updater application instance tries to read that dll. If I delete the dll, and then copy over the new one, the updater might not see the file, even though the manifest says that it should be there.

I have the idea of a sort of marker file, that will act as a synchronization object, and whose existence I and the updater instance can use as a lock, but is that not just moving the problem? There is still the time between checking if the lock is there, and making the lock, in which someone else could make the lock, and start modifying the ftp files. Plus, if some updater crashes before deleting the marker, there is no way of telling, whether the leftover marker should be deleted.

Edit: I also saw a suggestion to upload the files to another folder, and then rename the folder, since renames are supposed to be an atomic operation in ftp, but is it possible to just rename the folder to the name of an existing folder? Shouldn't the existing folder be deleted first, thus causing the same problem?

Is there a standard approach to solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

祁梦 2024-10-13 05:15:15

怎么样:在 FTP 服务器上,在文件名中包含版本信息。在客户端,下载后重命名文件。

How about this: On the FTP server, include version info in the filename. On the client, rename the file after downloading.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文