1
1
2
2
3
- # @generated function ==(x::FileDataEntry , y::FileDataEntry )
3
+ # @generated function ==(x::BlobEntry , y::BlobEntry )
4
4
# mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
5
5
# end
6
6
7
7
#
8
- # getHash(entry::AbstractDataEntry ) = hex2bytes(entry.hash)
8
+ # getHash(entry::AbstractBlobEntry ) = hex2bytes(entry.hash)
9
9
10
10
11
11
# #==============================================================================
12
- # # FileDataEntry Common
12
+ # # BlobEntry Common
13
13
# #==============================================================================
14
- blobfilename (entry:: FileDataEntry ) = joinpath (entry. folder," $(entry. id) .dat" )
15
- entryfilename (entry:: FileDataEntry ) = joinpath (entry. folder," $(entry. id) .json" )
14
+ blobfilename (entry:: BlobEntry ) = joinpath (entry. folder," $(entry. id) .dat" )
15
+ entryfilename (entry:: BlobEntry ) = joinpath (entry. folder," $(entry. id) .json" )
16
16
17
17
18
18
# #==============================================================================
19
- # # FileDataEntry Blob CRUD
19
+ # # BlobEntry Blob CRUD
20
20
# #==============================================================================
21
21
22
- function getDataBlob (dfg:: AbstractDFG , entry:: FileDataEntry )
22
+ function getBlob (dfg:: AbstractDFG , entry:: BlobEntry )
23
23
if isfile (blobfilename (entry))
24
24
open (blobfilename (entry)) do f
25
25
return read (f)
@@ -30,7 +30,7 @@ function getDataBlob(dfg::AbstractDFG, entry::FileDataEntry)
30
30
end
31
31
end
32
32
33
- function addDataBlob ! (dfg:: AbstractDFG , entry:: FileDataEntry , data:: Vector{UInt8} )
33
+ function addBlob ! (dfg:: AbstractDFG , entry:: BlobEntry , data:: Vector{UInt8} )
34
34
if isfile (blobfilename (entry))
35
35
error (" Key '$(entry. id) ' blob already exists." )
36
36
elseif isfile (entryfilename (entry))
@@ -42,37 +42,37 @@ function addDataBlob!(dfg::AbstractDFG, entry::FileDataEntry, data::Vector{UInt8
42
42
open (entryfilename (entry), " w" ) do f
43
43
JSON. print (f, entry)
44
44
end
45
- return getDataBlob (dfg, entry):: Vector{UInt8}
45
+ return getBlob (dfg, entry):: Vector{UInt8}
46
46
end
47
47
end
48
48
49
- function updateDataBlob ! (dfg:: AbstractDFG , entry:: FileDataEntry , data:: Vector{UInt8} )
49
+ function updateBlob ! (dfg:: AbstractDFG , entry:: BlobEntry , data:: Vector{UInt8} )
50
50
if ! isfile (blobfilename (entry))
51
51
@warn " Entry '$(entry. id) ' does not exist, adding."
52
- return addDataBlob ! (dfg, entry, data)
52
+ return addBlob ! (dfg, entry, data)
53
53
else
54
54
# perhaps add an explicit force update flag and error otherwise
55
55
@warn " Key '$(entry. id) ' already exists, data will be overwritten."
56
- deleteDataBlob ! (dfg, entry)
57
- return addDataBlob ! (dfg, entry, data)
56
+ deleteBlob ! (dfg, entry)
57
+ return addBlob ! (dfg, entry, data)
58
58
end
59
59
end
60
60
61
- function deleteDataBlob ! (dfg:: AbstractDFG , entry:: FileDataEntry )
62
- data = getDataBlob (dfg, entry)
61
+ function deleteBlob ! (dfg:: AbstractDFG , entry:: BlobEntry )
62
+ data = getBlob (dfg, entry)
63
63
rm (blobfilename (entry))
64
64
rm (entryfilename (entry))
65
65
return data
66
66
end
67
67
68
68
# #==============================================================================
69
- # # FileDataEntry CRUD Helpers
69
+ # # BlobEntry CRUD Helpers
70
70
# #==============================================================================
71
71
72
- function addData! (:: Type{FileDataEntry } , dfg:: AbstractDFG , label:: Symbol , key:: Symbol , folder:: String , blob:: Vector{UInt8} , timestamp= now (localzone ());
72
+ function addData! (:: Type{BlobEntry } , dfg:: AbstractDFG , label:: Symbol , key:: Symbol , folder:: String , blob:: Vector{UInt8} , timestamp= now (localzone ());
73
73
id:: UUID = uuid4 (), hashfunction = sha256)
74
- fde = FileDataEntry (key, id, folder, bytes2hex (hashfunction (blob)), timestamp)
74
+ fde = BlobEntry (key, id, folder, bytes2hex (hashfunction (blob)), timestamp)
75
75
de = addDataEntry! (dfg, label, fde)
76
- db = addDataBlob ! (dfg, fde, blob)
76
+ db = addBlob ! (dfg, fde, blob)
77
77
return de=> db
78
78
end
0 commit comments