Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix object-id is sometimes less than 24 chars in length (#6991) (#6994)

dyw770a78a2e4ae203
diff --git a/packages/core/src/utils/object-id.ts b/packages/core/src/utils/object-id.ts
index 8cab59bab..969fa7f8b 100644
--- a/packages/core/src/utils/object-id.ts
+++ b/packages/core/src/utils/object-id.ts
@@ -19,8 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
const MACHINE_ID = Math.floor(Math.random() * 0xffffff);
const pid = Math.floor(Math.random() * 100000) % 0xffff;
+const PROCESS_UNIQUE = MACHINE_ID.toString(16).padStart(6, "0") + pid.toString(16).padStart(4, "0");
let index = Math.floor(Math.random() * 0xffffff);
-const PROCESS_UNIQUE = MACHINE_ID.toString(16) + pid.toString(16);
+
export function createObjectId(date = Date.now()): string {
index++;
const time = Math.floor(date / 1000);
@@ -40,4 +41,4 @@ function swap16(val: number) {
export function getObjectIdTimestamp(id: string) {
return new Date(parseInt(id.substring(0, 8), 16) * 1000);
-}
+}
\ No newline at end of file