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

View File

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