Coder Social home page Coder Social logo

Prevent duplicates in blob store? about crate HOT 7 CLOSED

crate avatar crate commented on September 23, 2024
Prevent duplicates in blob store?

from crate.

Comments (7)

lukasender avatar lukasender commented on September 23, 2024

You could, for example, create a table 'file_index' which keeps a reference to a file for each user.
E.g.

CREATE TABLE file_index (
    user_name string,
    file string
);

If a user then deletes a file, you could only delete the reference which points to that file. The file would still be there for other users.

Could such a solution be of help?

from crate.

ddorian avatar ddorian commented on September 23, 2024

That is doable, but it would suck. Have to do a count(*) before every insert/delete.

from crate.

dobe avatar dobe commented on September 23, 2024

hi @ddorian

for inserts:
if you use the username and the digest of the file as primary key, there is no check required anymore on insert to prevent duplicates.

the "cleanup" of unused digests could be done asynchronously by a periodic task by selecting all used digests from your files table and comparing them to the existing digests. to prevent race conditions you could just delete files older than a day.

getting all stored digests of a blob table is currently not supported, but is already in progress and should make it into one of the next releases.

one other solution is to create an inode table with filenames like on normal filesystems, where the filename plays the same role as the username described above.

if you have other feature suggestions we would appreciate your feedback

thx, bernd

from crate.

ddorian avatar ddorian commented on September 23, 2024

So i can put anything i want in the 'digest' field when i write/upload a file ?

How are blobs stored? Is all the file stored in one server (not broken into pieces like riakcs) ?

from crate.

dobe avatar dobe commented on September 23, 2024

So i can put anything i want in the 'digest' field when i write/upload a file ?

i assume that you mean BLOB when you say file - so the answer is no, since the digest of a blob needs to be the hex encoded sha1 hash of the content (see also) https://crate.io/docs/current/blob.html . the digest is actually not a field it is the identifier of the blob, when a blob changes the digest changes too. note that there is currently no thing like a filesystem api on top of the crate BLOB support, but we have it on our roadmap.

How are blobs stored? Is all the file stored in one server (not broken into pieces like riakcs) ?

no blobs are not broken into pieces, they are stored as is. as of now the actual files on the filesystem can be verified via its name, since the name of the blob on the filesystem is the hash, this also makes blobs immutable.

from crate.

ddorian avatar ddorian commented on September 23, 2024

On Mon, May 5, 2014 at 2:52 PM, Bernd Dorn [email protected] wrote:

So i can put anything i want in the 'digest' field when i write/upload a
file ?

i assume that you mean BLOB when you say file - so the answer is no, since
the digest of a blob needs to be the hex encoded sha1 hash of the content
(see also) https://crate.io/docs/current/blob.html . the digest is
actually not a field it is the identifier of the blob, when a blob changes
the digest changes too. note that there is currently no thing like a
filesystem api on top of the crate BLOB support, but we have it on our
roadmap.

Why can't i store a unique-provided-by-the-client key instead of the
digest? Does the server confirm the digest?

How are blobs stored? Is all the file stored in one server (not broken
into pieces like riakcs) ?

no blobs are not broken into pieces, they are stored as is. as of now the
actual files on the filesystem can be verified via its name, since the name
of the blob on the filesystem is the hash, this also makes blobs immutable.


Reply to this email directly or view it on GitHubhttps://github.com//issues/735#issuecomment-42184206
.

from crate.

dobe avatar dobe commented on September 23, 2024

Why can't i store a unique-provided-by-the-client key instead of the
digest? Does the server confirm the digest?

yes, the server validates the digest, also it is used for routing the file to the right shard.

from crate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.