Require mtime sync

This commit is contained in:
2025-07-14 17:36:55 +02:00
parent 5896eeda7c
commit 896aef7565

View File

@ -79,6 +79,7 @@ private struct Action
What what;
string file;
string url;
size_t mtime;
alias this = what;
}
@ -227,6 +228,15 @@ private string workdir(string path)
}
private void touch(string path, size_t mtime = Clock.currTime().toUnixTime)
{
infof("Touching %s", path);
SysTime old_atime, old_mtime;
getTimes(path, old_atime, old_mtime);
setTimes(path, old_atime, SysTime.fromUnixTime(mtime));
}
private immutable(Remote) remote()
{
if (_remote_set)
@ -328,7 +338,8 @@ private immutable(Actions) actions()
auto this_act = Action(
Action.download,
workdir(this_rem.file),
this_rem.source
this_rem.source,
this_rem.mtime
);
auto this_loc = this_rem.file in loc;
@ -341,12 +352,17 @@ private immutable(Actions) actions()
to_be_deleted.remove(this_loc.file);
if (
(this_loc.mtime < this_rem.mtime) &&
(this_loc.hash != this_rem.hash)
){
act ~= this_act;
continue;
if (this_loc.mtime != this_rem.mtime)
{
if (this_loc.hash != this_rem.hash)
{
act ~= this_act;
continue;
}
else
{
touch(workdir(this_loc.file), this_rem.mtime);
}
}
else
{
@ -355,7 +371,7 @@ private immutable(Actions) actions()
}
foreach (file; to_be_deleted.byKey)
act ~= Action(Action.remove, workdir(file), "");
act ~= Action(Action.remove, workdir(file), "", 0);
cast()_actions = act;
_actions_set = true;
@ -405,6 +421,7 @@ public void update()
writefln("[%*d|%*d] %s", dl_pad, dl_count, dl_pad, dl_total, action.file);
}
download(action.url, action.file);
touch(action.file, action.mtime);
break;
}