mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 14:36:31 +00:00
fix(docsync): sort Papra's enumeration digest with an explicit comparator
SonarCloud flags a bare .sort() on strings (S2871). The comparator keeps the byte order the default sort used, so every cursor already stored stays valid.
This commit is contained in:
@@ -350,7 +350,9 @@ function inScope(doc: PapraDocument, tagId: string, serverFiltered: boolean): bo
|
||||
* complete set rather than from the newest entry.
|
||||
*/
|
||||
function enumerationDigest(documents: RemoteDocument[]): string {
|
||||
const pairs = documents.map((doc) => `${doc.remoteId}:${doc.remoteVersion}`).sort();
|
||||
const pairs = documents
|
||||
.map((doc) => `${doc.remoteId}:${doc.remoteVersion}`)
|
||||
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
||||
return crypto.createHash('sha256').update(pairs.join('\n')).digest('hex');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user