Skip to content

Commit

Permalink
Merge pull request #1040 from JuliaRobotics/23Q3/format/autoformat
Browse files Browse the repository at this point in the history
Run JuliaFormatter
  • Loading branch information
Affie authored Aug 18, 2023
2 parents 2c1b25c + ca9fc6a commit acd03da
Show file tree
Hide file tree
Showing 47 changed files with 4,200 additions and 2,876 deletions.
2 changes: 1 addition & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
indent = 2
indent = 4
always_for_in = false #
whitespace_typedefs = true
whitespace_ops_in_indices = true
Expand Down
26 changes: 16 additions & 10 deletions attic/DataBlobs/FileDataEntryBlob.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@


# @generated function ==(x::BlobEntry, y::BlobEntry)
# mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
# end

#
# getHash(entry::AbstractBlobEntry) = hex2bytes(entry.hash)


##==============================================================================
## BlobEntry Common
##==============================================================================
blobfilename(entry::BlobEntry) = joinpath(entry.folder,"$(entry.id).dat")
entryfilename(entry::BlobEntry) = joinpath(entry.folder,"$(entry.id).json")

blobfilename(entry::BlobEntry) = joinpath(entry.folder, "$(entry.id).dat")
entryfilename(entry::BlobEntry) = joinpath(entry.folder, "$(entry.id).json")

##==============================================================================
## BlobEntry Blob CRUD
Expand All @@ -37,10 +34,10 @@ function addBlob!(dfg::AbstractDFG, entry::BlobEntry, data::Vector{UInt8})
error("Key '$(entry.id)' entry already exists, but no blob.")
else
open(blobfilename(entry), "w") do f
write(f, data)
return write(f, data)
end
open(entryfilename(entry), "w") do f
JSON.print(f, entry)
return JSON.print(f, entry)
end
# FIXME update for entry.blobId vs entry.originId
return UUID(entry.id)
Expand Down Expand Up @@ -71,11 +68,20 @@ end
## BlobEntry CRUD Helpers
##==============================================================================

function addData!(::Type{BlobEntry}, dfg::AbstractDFG, label::Symbol, key::Symbol, folder::String, blob::Vector{UInt8}, timestamp=now(localzone());
id::UUID = uuid4(), hashfunction = sha256)
function addData!(
::Type{BlobEntry},
dfg::AbstractDFG,
label::Symbol,
key::Symbol,
folder::String,
blob::Vector{UInt8},
timestamp = now(localzone());
id::UUID = uuid4(),
hashfunction = sha256,
)
fde = BlobEntry(key, id, folder, bytes2hex(hashfunction(blob)), timestamp)
blobId = addBlob!(dfg, fde, blob) |> UUID
newEntry = BlobEntry(fde; id=blobId, blobId)
newEntry = BlobEntry(fde; id = blobId, blobId)
de = addBlobEntry!(dfg, label, newEntry)
return de # de=>db
end
Loading

0 comments on commit acd03da

Please sign in to comment.