Using large uids to avoid metadata colision.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-03-09 17:53:57 -05:00
parent 7802cfe8f5
commit 67cb81497b
1 changed files with 15 additions and 4 deletions

View File

@ -136,6 +136,11 @@ Tiddler >> customFields [
^ customFields ifNil: [ customFields := Dictionary new]
]
{ #category : #accessing }
Tiddler >> deleteUid [
self customFields deleteKey: 'uid'.
]
{ #category : #accessing }
Tiddler >> exportJSONFile [
| jsonFile |
@ -155,7 +160,7 @@ Tiddler >> exportSTONFileInto: subfolder [
| stonFile output dashedTitle sanitized |
dashedTitle := '-' join: (self title substrings collect: [ :each | each ]).
sanitized := dashedTitle copyWithoutAll: #($¿ $? $! $/).
stonFile := self wiki file parent / subfolder / (sanitized, '--', self uid, '.ston').
stonFile := self wiki file parent / subfolder / (sanitized, '--', (self uid copyFrom: 1 to: 5), '.ston').
^ MarkupFile exportAsFileOn: stonFile containing: self asStonStringPretty
]
@ -458,13 +463,19 @@ Tiddler >> type: anObject [
{ #category : #accessing }
Tiddler >> uid [
^ self customFields at: 'uid' ifAbsentPut: [ self uidGenerator ].
]
{ #category : #accessing }
Tiddler >> uidGenerator [
| tempId |
self created
ifNotNil: [ tempId := self created hash hex copyFrom: 1 to: 5. ]
ifNil: [ tempId := self class nowLocal hash hex copyFrom: 1 to: 5 ].
ifNotNil: [ tempId := self created hash hex. ]
ifNil: [ tempId := self class nowLocal hash hex ].
self customFields at: 'uid' put: tempId .
^ tempId
]
{ #category : #accessing }