Git Product home page Git Product logo

Comments (20)

lingol avatar lingol commented on May 22, 2024

Well, MMKV uses id as filename. For the time being, just don't do this.

from mmkv.

rednels avatar rednels commented on May 22, 2024

Why not Hash Code or MD5

from mmkv.

lingol avatar lingol commented on May 22, 2024

Why not Hash Code or MD5

It's already shipped. Now is too late for that. That's why.

from mmkv.

ysbing avatar ysbing commented on May 22, 2024

Why not Hash Code or MD5

It's already shipped. Now is too late for that. That's why.

Is it possible to encode only special characters?

from mmkv.

lingol avatar lingol commented on May 22, 2024

Is it possible to encode only special characters?

Or just throw exception on bad id?

Encoding special char is always complicated. Say you replaces / with _, now how do you handle normal _? With __? Now don't forget there may already be some id that has an _, how do you handle old id?

from mmkv.

zhongwuzw avatar zhongwuzw commented on May 22, 2024

Is this related to Android? I don't familiar with it, butI think we can find the issue character and just encode it, the way like encodeURI which transform certain characters using escape sequences.

from mmkv.

lingol avatar lingol commented on May 22, 2024

Is this related to Android? I don't familiar with it, butI think we can find the issue character and just encode it, the way like encodeURI which transform certain characters using escape sequences.

No. It has nothing to do with Android. All those ecodeXXX has the same problem I described before: they don't support backward compatibility.

from mmkv.

lingol avatar lingol commented on May 22, 2024

Is it possible to encode only special characters?

Or just throw exception on bad id?

Fixed with commit.

from mmkv.

ysbing avatar ysbing commented on May 22, 2024

Other char?
qwe

from mmkv.

lingol avatar lingol commented on May 22, 2024

Other char?
qwe

Hmm...

from mmkv.

zhongwuzw avatar zhongwuzw commented on May 22, 2024

@lingol

No. It has nothing to do with Android. All those ecodeXXX has the same problem I described before: they don't support backward compatibility.

No backward compatible? I think it compatible, previously it would crash, after encode specific char, it works.

from mmkv.

lingol avatar lingol commented on May 22, 2024

No backward compatible? I think it compatible, previously it would crash, after encode specific char, it works.

Encoding special char is always complicated. Say you replaces / with _, now how do you handle normal _? With __? Now don't forget there may already be some id that has an _, how do you handle old id?

Had I not been clear? Those encodeXXX algorithms, no matter which char(s) they choose to escape, are choosing valid chars to escape with. And how do they handle these valid chars themself? They do double escape. That's where the No backward compatible happens.

from mmkv.

zhongwuzw avatar zhongwuzw commented on May 22, 2024

@lingol First, scan the mmkvID, if it exist special character (which leads to crash), encode it and using a separate sub-directory in directory mmkv to store these files which have special characters. If it not have special character, keep the regular way.

from mmkv.

lingol avatar lingol commented on May 22, 2024

@zhongwuzw

Say we replace / with _.

Given test/hello2, we get test_hello2, right? Everything goes well. Except if there is some one already create a MMKV instance with test_hello2.

Now tell me, how do you handle this collision?

from mmkv.

zhongwuzw avatar zhongwuzw commented on May 22, 2024

@lingol Emm, maybe you don't get what I point 😂 . I'll explain further, as your example, if given test/hello2, we find it contains special character /, so we encode it to test_hello2, and besides this, we add a separate subdirectory to store the file, so file would be stored in mmkv/special-character/ directory (PS. for id which not contains special character, we still store the files in mmkv/ directory). So no collision would be happen.

from mmkv.

ajinwu avatar ajinwu commented on May 22, 2024

from mmkv.

lingol avatar lingol commented on May 22, 2024

@zhongwuzw That might just work. Would you like to write a pr?

from mmkv.

zhongwuzw avatar zhongwuzw commented on May 22, 2024

@lingol Yeah, I can, but firstly, I need to confirm something because I'm not familiar Android, the reason which causes crash is the file cannot created? because intermediate directories not exist if id contains /? If it is, I think we only need to modify implementation mappedKVPathWithID and crcPathWithID, and judge wether contains /, if existed, encode it and create a separate sub-directory, am I right?

from mmkv.

lingol avatar lingol commented on May 22, 2024

Other char?
qwe

@zhongwuzw Not just /.

from mmkv.

lingol avatar lingol commented on May 22, 2024

Release with v1.0.13.

from mmkv.

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.