FileFd::stat fixes.
GitOrigin-RevId: 36197c4d134e4afe902eef066dc497c03228c271
This commit is contained in:
parent
8cf10f3fd3
commit
c5eace2057
@ -164,7 +164,8 @@ Result<FileLoader::PrefixInfo> FileUploader::on_update_local_location(const Loca
|
|||||||
|
|
||||||
if (local_is_ready) {
|
if (local_is_ready) {
|
||||||
CHECK(!fd_.empty());
|
CHECK(!fd_.empty());
|
||||||
TRY_RESULT(local_size, fd_.get_size());
|
TRY_RESULT(local_file_size, fd_.get_size());
|
||||||
|
local_size = local_file_size;
|
||||||
LOG(INFO) << "Set file local_size to " << local_size;
|
LOG(INFO) << "Set file local_size to " << local_size;
|
||||||
if (local_size == 0) {
|
if (local_size == 0) {
|
||||||
return Status::Error("Can't upload empty file");
|
return Status::Error("Can't upload empty file");
|
||||||
|
@ -446,19 +446,17 @@ Result<Stat> FileFd::stat() {
|
|||||||
FILE_BASIC_INFO basic_info;
|
FILE_BASIC_INFO basic_info;
|
||||||
auto status = GetFileInformationByHandleEx(get_native_fd().fd(), FileBasicInfo, &basic_info, sizeof(basic_info));
|
auto status = GetFileInformationByHandleEx(get_native_fd().fd(), FileBasicInfo, &basic_info, sizeof(basic_info));
|
||||||
if (!status) {
|
if (!status) {
|
||||||
auto error = OS_ERROR("Stat failed");
|
return OS_ERROR("Get FileBasicInfo failed");
|
||||||
LOG(FATAL) << error;
|
|
||||||
}
|
}
|
||||||
res.atime_nsec_ = filetime_to_unix_time_nsec(basic_info.LastAccessTime.QuadPart);
|
res.atime_nsec_ = filetime_to_unix_time_nsec(basic_info.LastAccessTime.QuadPart);
|
||||||
res.mtime_nsec_ = filetime_to_unix_time_nsec(basic_info.LastWriteTime.QuadPart);
|
res.mtime_nsec_ = filetime_to_unix_time_nsec(basic_info.LastWriteTime.QuadPart);
|
||||||
res.is_dir_ = (basic_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
res.is_dir_ = (basic_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
res.is_reg_ = true;
|
res.is_reg_ = !res.is_dir_; // TODO this is still wrong
|
||||||
|
|
||||||
FILE_STANDARD_INFO standard_info;
|
FILE_STANDARD_INFO standard_info;
|
||||||
status = GetFileInformationByHandleEx(get_native_fd().fd(), FileStandardInfo, &standard_info, sizeof(standard_info));
|
status = GetFileInformationByHandleEx(get_native_fd().fd(), FileStandardInfo, &standard_info, sizeof(standard_info));
|
||||||
if (!status) {
|
if (!status) {
|
||||||
auto error = OS_ERROR("Stat failed");
|
return OS_ERROR("Get FileStandardInfo failed");
|
||||||
LOG(FATAL) << error;
|
|
||||||
}
|
}
|
||||||
res.size_ = standard_info.EndOfFile.QuadPart;
|
res.size_ = standard_info.EndOfFile.QuadPart;
|
||||||
|
|
||||||
|
@ -113,10 +113,8 @@ Stat from_native_stat(const struct ::stat &buf) {
|
|||||||
|
|
||||||
Result<Stat> fstat(int native_fd) {
|
Result<Stat> fstat(int native_fd) {
|
||||||
struct ::stat buf;
|
struct ::stat buf;
|
||||||
int err = detail::skip_eintr([&] { return ::fstat(native_fd, &buf); });
|
if (detail::skip_eintr([&] { return ::fstat(native_fd, &buf); }) < 0) {
|
||||||
auto fstat_errno = errno;
|
return OS_ERROR(PSLICE() << "Stat for fd " << native_fd << " failed");
|
||||||
if (err < 0) {
|
|
||||||
return Status::PosixError(fstat_errno, PSLICE() << "Stat for fd " << native_fd << " failed");
|
|
||||||
}
|
}
|
||||||
return detail::from_native_stat(buf);
|
return detail::from_native_stat(buf);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user