authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-16 22:49:28-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-16 22:50:04-05:00
loga5d47be5adc7c493ff7e87fc47241a84e268a3f0
tree501bdbe866f76b5ddd55c098290e7bc7864c2290
parentd5860cbade79141c4c547a3411befb8448dd56ab
signaturelock-open Commit is signed but in an unrecognized format.

stage1 os_update_file additionally compares src and dest size

prevents problems when source is created and then immediately copied to dest.

2 files changed, 7 insertions(+), 3 deletions(-)

src/os.cpp+6-3
......@@ -1108,9 +1108,10 @@ Error os_update_file(Buf *src_path, Buf *dst_path) {
11081108 return err;
11091109 }
11101110
1111 if (src_attr.mtime.sec == dst_attr.mtime.sec &&
1112 src_attr.mtime.nsec == dst_attr.mtime.nsec &&
1113 src_attr.mode == dst_attr.mode)
1111 if (src_attr.size == dst_attr.size &&
1112 src_attr.mode == dst_attr.mode &&
1113 src_attr.mtime.sec == dst_attr.mtime.sec &&
1114 src_attr.mtime.nsec == dst_attr.mtime.nsec)
11141115 {
11151116 os_file_close(&src_file);
11161117 os_file_close(&dst_file);
......@@ -1871,6 +1872,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n
18711872 windows_filetime_to_os_timestamp(&file_info.ftLastWriteTime, &attr->mtime);
18721873 attr->inode = (((uint64_t)file_info.nFileIndexHigh) << 32) | file_info.nFileIndexLow;
18731874 attr->mode = 0;
1875 attr->size = (((uint64_t)file_info.nFileSizeHigh) << 32) | file_info.nFileSizeLow;
18741876 }
18751877
18761878 return ErrorNone;
......@@ -1918,6 +1920,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n
19181920 attr->mtime.nsec = statbuf.st_mtim.tv_nsec;
19191921#endif
19201922 attr->mode = statbuf.st_mode;
1923 attr->size = statbuf.st_size;
19211924 }
19221925 return ErrorNone;
19231926 }
src/os.hpp+1
......@@ -99,6 +99,7 @@ struct OsTimeStamp {
9999
100100struct OsFileAttr {
101101 OsTimeStamp mtime;
102 uint64_t size;
102103 uint64_t inode;
103104 uint32_t mode;
104105};