1
1
2
-
3
2
# @generated function ==(x::BlobEntry, y::BlobEntry)
4
3
# mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
5
4
# end
6
5
7
6
#
8
7
# getHash(entry::AbstractBlobEntry) = hex2bytes(entry.hash)
9
8
10
-
11
9
# #==============================================================================
12
10
# # BlobEntry Common
13
11
# #==============================================================================
14
- blobfilename (entry:: BlobEntry ) = joinpath (entry. folder," $(entry. id) .dat" )
15
- entryfilename (entry:: BlobEntry ) = joinpath (entry. folder," $(entry. id) .json" )
16
-
12
+ blobfilename (entry:: BlobEntry ) = joinpath (entry. folder, " $(entry. id) .dat" )
13
+ entryfilename (entry:: BlobEntry ) = joinpath (entry. folder, " $(entry. id) .json" )
17
14
18
15
# #==============================================================================
19
16
# # BlobEntry Blob CRUD
@@ -37,10 +34,10 @@ function addBlob!(dfg::AbstractDFG, entry::BlobEntry, data::Vector{UInt8})
37
34
error (" Key '$(entry. id) ' entry already exists, but no blob." )
38
35
else
39
36
open (blobfilename (entry), " w" ) do f
40
- write (f, data)
37
+ return write (f, data)
41
38
end
42
39
open (entryfilename (entry), " w" ) do f
43
- JSON. print (f, entry)
40
+ return JSON. print (f, entry)
44
41
end
45
42
# FIXME update for entry.blobId vs entry.originId
46
43
return UUID (entry. id)
71
68
# # BlobEntry CRUD Helpers
72
69
# #==============================================================================
73
70
74
- function addData! (:: Type{BlobEntry} , dfg:: AbstractDFG , label:: Symbol , key:: Symbol , folder:: String , blob:: Vector{UInt8} , timestamp= now (localzone ());
75
- id:: UUID = uuid4 (), hashfunction = sha256)
71
+ function addData! (
72
+ :: Type{BlobEntry} ,
73
+ dfg:: AbstractDFG ,
74
+ label:: Symbol ,
75
+ key:: Symbol ,
76
+ folder:: String ,
77
+ blob:: Vector{UInt8} ,
78
+ timestamp = now (localzone ());
79
+ id:: UUID = uuid4 (),
80
+ hashfunction = sha256,
81
+ )
76
82
fde = BlobEntry (key, id, folder, bytes2hex (hashfunction (blob)), timestamp)
77
83
blobId = addBlob! (dfg, fde, blob) |> UUID
78
- newEntry = BlobEntry (fde; id= blobId, blobId)
84
+ newEntry = BlobEntry (fde; id = blobId, blobId)
79
85
de = addBlobEntry! (dfg, label, newEntry)
80
86
return de # de=>db
81
87
end
0 commit comments