Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Avoiding loading and processing same cert file to improve cold start performance …#97267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bartonjs merged 4 commits intodotnet:mainfrombirojnayak:cert-load-fix-forAL2023
Jan 26, 2024
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Incorporated feedback
  • Loading branch information
Biroj committedJan 22, 2024
commit9efa5b7b0df86b6f988ce2491f86de043ae6cf9d
Original file line numberDiff line numberDiff line change
Expand Up@@ -198,27 +198,21 @@ bool ProcessDir(string dir, out DateTime lastModified)

foreach (string file in Directory.EnumerateFiles(dir))
{
hasStoreData |= ProcessFile(file, out _, skipStat: true);
hasStoreData |= ProcessFile(file, out _);
}

return hasStoreData;
}

bool ProcessFile(string file, out DateTime lastModified, bool skipStat = false)
bool ProcessFile(string file, out DateTime lastModified)
{
bool readData = false;
bool result = TryStatFile(file, out lastModified, out (long, long) fileDetails);

if (skipStat)
{
lastModified = default;
}
else if (!result)
if (!TryStatFile(file, out lastModified, out (long, long) fileId))
{
return false;
}

if (processedFiles.Contains(fileDetails))
if (processedFiles.Contains(fileId))
{
return true;
}
Expand DownExpand Up@@ -290,7 +284,7 @@ bool ProcessFile(string file, out DateTime lastModified, bool skipStat = false)

if (readData)
{
processedFiles.Add(fileDetails);
processedFiles.Add(fileId);
}

return readData;
Expand DownExpand Up@@ -373,32 +367,28 @@ private static string[] GetRootStoreDirectories(out bool isDefault)
}

private static bool TryStatFile(string path, out DateTime lastModified)
=> CallStat(path, Interop.Sys.FileTypes.S_IFREG, out lastModified).HasCallSucceed;
=> CallStat(path, Interop.Sys.FileTypes.S_IFREG, out lastModified, out _);

private static bool TryStatDirectory(string path, out DateTime lastModified)
=> CallStat(path, Interop.Sys.FileTypes.S_IFDIR, out lastModified).HasCallSucceed;
=> CallStat(path, Interop.Sys.FileTypes.S_IFDIR, out lastModified, out _);

private static bool TryStatFile(string path, out DateTime lastModified, out (long Ino, long Dev) fileDetails)
{
var statResult = CallStat(path, Interop.Sys.FileTypes.S_IFREG, out lastModified);
fileDetails = (statResult.fileStatus.Ino, statResult.fileStatus.Dev);
return statResult.HasCallSucceed;
}
private static bool TryStatFile(string path, out DateTime lastModified, out (long, long) fileId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: only keep 1TryStatFile and update the caller that ignoresfileId by passing itout _ as the last argument.

birojnayak reacted with thumbs up emoji
=> CallStat(path, Interop.Sys.FileTypes.S_IFREG, out lastModified, out fileId);

private static(boolHasCallSucceed, Interop.Sys.FileStatus fileStatus)CallStat(string path, int fileType, out DateTime lastModified)
private static bool CallStat(string path, int fileType, out DateTime lastModified, out (long, long) fileId)
{
lastModified = default;

Interop.Sys.FileStatus status;
fileId = default;
// Use Stat to follow links.
if (Interop.Sys.Stat(path, out status) < 0 ||
if (Interop.Sys.Stat(path, outInterop.Sys.FileStatusstatus) < 0 ||
(status.Mode & Interop.Sys.FileTypes.S_IFMT) != fileType)
{
return(false, status);
return false;
}

fileId = (status.Ino, status.Dev);
lastModified = DateTime.UnixEpoch + TimeSpan.FromTicks(status.MTime * TimeSpan.TicksPerSecond + status.MTimeNsec / TimeSpan.NanosecondsPerTick);
return(true, status);
return true;
}
}
}

[8]ページ先頭

©2009-2025 Movatter.jp