Skip to content

Commit

Permalink
build: add macos build patch (#1876)
Browse files Browse the repository at this point in the history
- Fixes #1867
- Relates to Homebrew/homebrew-core#169388

Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
chenrui333 authored Apr 19, 2024
1 parent 6c63420 commit 9e39407
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/llm-cache/storage/file_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ void FileStorage::PrintFileAccessTime(std::string path) {

std::string FileStorage::GetTimestamp(
std::chrono::duration<int64_t, std::nano> time) {
std::chrono::time_point<std::chrono::system_clock> timestamp =
std::chrono::time_point<std::chrono::system_clock>(time);
auto duration_since_epoch = std::chrono::duration_cast<std::chrono::system_clock::duration>(time);
std::chrono::time_point<std::chrono::system_clock> timestamp = std::chrono::system_clock::time_point(duration_since_epoch);
time_t t = std::chrono::system_clock::to_time_t(timestamp);

std::tm tm;
Expand Down
9 changes: 7 additions & 2 deletions modules/llm-cache/storage/local_file_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,13 @@ Status LocalFileStorage::GetFileAccessTime(
return Status::IOError("Failed to get file access time: " +
formatIOError(path));
}
accessTime = std::chrono::duration<int64_t, std::nano>(
statbuf.st_atim.tv_sec * SECOND_TO_NANOSECOND + statbuf.st_atim.tv_nsec);
#ifdef __APPLE__
accessTime = std::chrono::duration<int64_t, std::nano>(
statbuf.st_atimespec.tv_sec * SECOND_TO_NANOSECOND + statbuf.st_atimespec.tv_nsec);
#else
accessTime = std::chrono::duration<int64_t, std::nano>(
statbuf.st_atim.tv_sec * SECOND_TO_NANOSECOND + statbuf.st_atim.tv_nsec);
#endif
return Status::OK();
}

Expand Down

0 comments on commit 9e39407

Please sign in to comment.