Skip to content

Commit

Permalink
Fixed patterns in mtdir when introduced a subfolder
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Mar 30, 2024
1 parent 558c024 commit 5d87541
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,6 @@ ubyte[] hashFile(Digest digest, string path)
// NOTE: file can be a stream!
ubyte[] hashFile(Digest digest, ref File file)
{
version (Trace) trace("path=%s", path);

try
{
digest.reset();
Expand Down Expand Up @@ -541,8 +539,6 @@ int processList(string path, bool autodetect, Style style)
// Parse entry hash to byte array
ubyte[] hashExpected = unformatHex(entryHash);

version (Trace) trace("result=%s expected=%s", result, expected);

// Compare binary hashes.
// secureEqual is used in case this is used server-side.
if (secureEqual(hashResult, hashExpected) == false)
Expand Down Expand Up @@ -852,8 +848,9 @@ void main(string[] args)
{
try
{
scope pattern = baseName(entry); // Extract pattern
scope folder = dirName(entry); // Results to "." by default
scope pattern = baseName(entry); // Extract pattern
version (Trace) trace("folder=%s pattern=%s", folder, pattern);
dirEntriesMT(folder, pattern, options.span, !onofollow,
&initThreadDigest, &mtDirEntry, othreads);
}
Expand Down
6 changes: 3 additions & 3 deletions src/mtdir.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module mtdir;

import std.concurrency;
import std.file;
import std.path : globMatch;
import std.path : globMatch, baseName;
import std.parallelism : totalCPUs;

//TODO: Find a way to construct dirEntries iterator.
Expand Down Expand Up @@ -65,7 +65,7 @@ void dirEntriesSTImpl(string path, string pattern, SpanMode mode, bool follow,
immutable(void)* uobj = fnspawn();
foreach (DirEntry entry; dirEntries(path, mode, follow))
{
if (pattern && globMatch(entry.name, pattern) == false)
if (pattern && globMatch(baseName(entry.name), pattern) == false)
continue;
fnentry(entry, uobj);
}
Expand Down Expand Up @@ -95,7 +95,7 @@ void dirEntriesMTImpl(string path, string pattern, SpanMode mode, bool followLin
int cur; // Current thread index
foreach (DirEntry entry; dirEntries(path, mode, followLinks))
{
if (pattern && globMatch(entry.name, pattern) == false)
if (pattern && globMatch(baseName(entry.name), pattern) == false)
continue;
send(pool[cur], MsgEntry(entry));
if (++cur >= threads) cur = 0;
Expand Down

0 comments on commit 5d87541

Please sign in to comment.