stage1 os_update_file additionally compares src and dest size

prevents problems when source is created and then immediately copied to
dest.
This commit is contained in:
Andrew Kelley 2020-02-16 22:49:28 -05:00
parent d5860cbade
commit a5d47be5ad
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 7 additions and 3 deletions

View File

@ -1108,9 +1108,10 @@ Error os_update_file(Buf *src_path, Buf *dst_path) {
return err;
}
if (src_attr.mtime.sec == dst_attr.mtime.sec &&
src_attr.mtime.nsec == dst_attr.mtime.nsec &&
src_attr.mode == dst_attr.mode)
if (src_attr.size == dst_attr.size &&
src_attr.mode == dst_attr.mode &&
src_attr.mtime.sec == dst_attr.mtime.sec &&
src_attr.mtime.nsec == dst_attr.mtime.nsec)
{
os_file_close(&src_file);
os_file_close(&dst_file);
@ -1871,6 +1872,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n
windows_filetime_to_os_timestamp(&file_info.ftLastWriteTime, &attr->mtime);
attr->inode = (((uint64_t)file_info.nFileIndexHigh) << 32) | file_info.nFileIndexLow;
attr->mode = 0;
attr->size = (((uint64_t)file_info.nFileSizeHigh) << 32) | file_info.nFileSizeLow;
}
return ErrorNone;
@ -1918,6 +1920,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n
attr->mtime.nsec = statbuf.st_mtim.tv_nsec;
#endif
attr->mode = statbuf.st_mode;
attr->size = statbuf.st_size;
}
return ErrorNone;
}

View File

@ -99,6 +99,7 @@ struct OsTimeStamp {
struct OsFileAttr {
OsTimeStamp mtime;
uint64_t size;
uint64_t inode;
uint32_t mode;
};