mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-08 09:36:48 +01:00
Use strpos instead of strstr
Instead of just finding our dirname within the finalArray using strstr, now using strpos and detecting if it's pos 0, which is much more appropriate & reliable. Example: Looking for /bob/t1.txt for may potentially return a false positive for finding '/bob' in '/another/bob1/abc' and files therefore t1.txt ends up in the wrong folder. This false positive only occurs when the write order of hard drive storage has stored another/bob1/abc before /bob and therefore retrieval load order can cause this odd, occasional issue. Checking for /bob being the start of our finalArray item through strpos===0 eliminates this possibility.
This commit is contained in:
@@ -66,7 +66,7 @@ for ($i=0;$i<count($tempArray);$i++) {
|
||||
for ($j=$insertAt;$j<count($finalArray);$j++) {
|
||||
if ( strcasecmp(dirname($finalArray[$j]), dirname($tempArray[$i]))==0 &&
|
||||
strcasecmp(basename($finalArray[$j]), basename($tempArray[$i]))<0 ||
|
||||
strstr(dirname($finalArray[$j]),dirname($tempArray[$i]))) {
|
||||
strpos(dirname($finalArray[$j]),dirname($tempArray[$i]))===0) {
|
||||
$insertAt++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user