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) {...@@ -1108,9 +1108,10 @@ Error os_update_file(Buf *src_path, Buf *dst_path) {
1108 return err;1108 return err;
1109 }1109 }
11101110
1111 if (src_attr.mtime.sec == dst_attr.mtime.sec &&1111 if (src_attr.size == dst_attr.size &&
1112 src_attr.mtime.nsec == dst_attr.mtime.nsec &&1112 src_attr.mode == dst_attr.mode &&
1113 src_attr.mode == dst_attr.mode)1113 src_attr.mtime.sec == dst_attr.mtime.sec &&
1114 src_attr.mtime.nsec == dst_attr.mtime.nsec)
1114 {1115 {
1115 os_file_close(&src_file);1116 os_file_close(&src_file);
1116 os_file_close(&dst_file);1117 os_file_close(&dst_file);
...@@ -1871,6 +1872,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n...@@ -1871,6 +1872,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n
1871 windows_filetime_to_os_timestamp(&file_info.ftLastWriteTime, &attr->mtime);1872 windows_filetime_to_os_timestamp(&file_info.ftLastWriteTime, &attr->mtime);
1872 attr->inode = (((uint64_t)file_info.nFileIndexHigh) << 32) | file_info.nFileIndexLow;1873 attr->inode = (((uint64_t)file_info.nFileIndexHigh) << 32) | file_info.nFileIndexLow;
1873 attr->mode = 0;1874 attr->mode = 0;
1875 attr->size = (((uint64_t)file_info.nFileSizeHigh) << 32) | file_info.nFileSizeLow;
1874 }1876 }
18751877
1876 return ErrorNone;1878 return ErrorNone;
...@@ -1918,6 +1920,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n...@@ -1918,6 +1920,7 @@ Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool n
1918 attr->mtime.nsec = statbuf.st_mtim.tv_nsec;1920 attr->mtime.nsec = statbuf.st_mtim.tv_nsec;
1919#endif1921#endif
1920 attr->mode = statbuf.st_mode;1922 attr->mode = statbuf.st_mode;
1923 attr->size = statbuf.st_size;
1921 }1924 }
1922 return ErrorNone;1925 return ErrorNone;
1923 }1926 }
src/os.hpp+1
...@@ -99,6 +99,7 @@ struct OsTimeStamp {...@@ -99,6 +99,7 @@ struct OsTimeStamp {
9999
100struct OsFileAttr {100struct OsFileAttr {
101 OsTimeStamp mtime;101 OsTimeStamp mtime;
102 uint64_t size;
102 uint64_t inode;103 uint64_t inode;
103 uint32_t mode;104 uint32_t mode;
104};105};