[英]How exactly does Cargo detect file changes?
tl;dr: I want to know what cargo
uses to determine whether or not a file has changed to debug a problem I've observed in my build system setup. tl; dr:我想知道cargo
使用什么来确定文件是否已更改以调试我在构建系统设置中观察到的问题。
I currently have lsyncd
setup to mirror project files onto a remote linux machine where I compile code via ENVVARS_HERE=$my_values cargo build
.我目前有lsyncd
设置将项目文件镜像到远程 linux 机器上,我通过ENVVARS_HERE=$my_values cargo build
编译代码。 lsyncd
's use of rsync
w/ the archive flag
unfortunately seems to not copy over whatever attribute it is that cargo
uses to determine whether or not a file has been edited: lsyncd
的是, lsyncd
使用带有archive flag
的rsync
似乎没有复制cargo
用来确定文件是否已被编辑的任何属性:
I have a workspace set up:我设置了一个工作区:
workspace
+ crateA
+ ...
+ crateB
+ ...
where crateB
depends on crateA
.其中crateB
取决于crateA
。 Henceforth, 'remote machine' refers to the machine on which cargo
is invoked, and 'local machine' refers to a machine editing the code that lsyncd
then passes onto the 'remote machine'.此后,“远程机器”是指调用cargo
的机器,“本地机器”是指编辑lsyncd
然后传递到“远程机器”的代码的机器。 I will use 'recently' to refer to any time during which the dependencies of the action being described have not been changed relative to the state being described in a manner I am aware of.我将使用“最近”来指代所描述的动作的依赖关系没有以我所知道的方式相对于所描述的状态发生变化的任何时间。
Initial state:初始状态:
lsyncd
is not running on the local machine lsyncd
没有在本地机器上运行crateB
has been compiled recently by cargo build
on the remote machine crateB
最近由远程机器上的cargo build
编译Perform:履行:
crateB
on the remote machine在远程机器上编辑crateB
中的源文件cargo build
on the remote machine在远程机器上调用cargo build
Result:结果:
crateB
is recompiled by cargo
on the remote machine crateB
被远程机器上的cargo
重新编译Initial state:初始状态:
lsyncd
is running on the local machine (see notes below regarding configuration) lsyncd
在本地机器上运行(参见关于配置下面的注释)crateB
has been compiled recently by cargo build
on the remote machine (see notes regarding timing relative to lsyncd
's operation modes) crateB
最近由远程机器上的cargo build
编译(请参阅有关与lsyncd
操作模式相关的时间的注释)Perform:履行:
crateB
file on local machine在本地机器上编辑crateB
文件cargo build
on remote machine在远程机器上调用cargo build
Result:结果:
crateA
compiles on the remote machine, followed by crateB
crateA
在远程机器上编译,然后是crateB
lsyncd
was run both with and without archive = true
(which to the best of my knowledge sets rsync's archive
flag to copy 'most' metadata, where 'most' appears to miss whatever it is that cargo
cares about), with no observed change in the results. lsyncd
在有和没有archive = true
情况下运行(据我所知,这将 rsync 的archive
标志设置为复制“最”元数据,其中“最”似乎错过了cargo
关心的任何内容),没有观察到任何变化结果。lsyncd
was present was tested for the following cases with no observed changes in the results: compilation before lsyncd
's initial pass, and compilation after lsyncd
's initial pass针对以下情况测试了存在lsyncd
初始状态的编译,结果中没有观察到任何变化: lsyncd
的初始传递之前的编译,以及lsyncd
的初始传递之后的编译lsyncd
on the remote machine is on a tmpfs
filesystem (if that makes some arcane difference)远程机器上lsyncd
的目标目录位于tmpfs
文件系统上(如果这会产生一些神秘的差异)I want a way to suss out what's going on here, both in this situation with lsyncd
and in the future if/when I give up on lsyncd
for some other approach that stumbles on a similar problem.我想要一种方法来弄清楚这里发生了什么,无论是在lsyncd
这种情况下, lsyncd
在未来,如果/当我放弃lsyncd
而采用其他一些lsyncd
发现类似问题的方法时。 Sources regarding cargo
on eg SO reference the use of timestamps, but there are many kinds of timestamps and which timestamp they refer to is unclear.关于例如 SO 上的cargo
来源引用了时间戳的使用,但是时间戳有很多种,它们指的是哪个时间戳尚不清楚。
What exactly does cargo
check for when determining whether or not a file has changed?在确定文件是否已更改时, cargo
究竟会检查什么?
So cargo uses fingerprints to track change metadata.因此,货物使用指纹来跟踪更改元数据。
Seems to me from reading the code that it's related to mtime
, the modified time;在我看来,阅读与mtime
相关的代码,修改时间; fingerprint::find_stale_file and paths::mtime_recursive . 指纹::find_stale_file和paths::mtime_recursive 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.