GithubHelp home page GithubHelp logo

Comments (9)

monde avatar monde commented on July 1, 2024

Could you be re-using the same mail fixtures over and over in your test suite? If so, the test suite could be clobbering results. If that is the case you could submit a patch that creates a truely random director for @media_dir

from mms2r.

kbaum avatar kbaum commented on July 1, 2024

This could indeed be the case.

For generating random file names, I've had success using:

UUIDTools::UUID.random_create.to_s

Do you think that would make sense?

thx

from mms2r.

monde avatar monde commented on July 1, 2024

I think you can keep it simple by introducing the current time or a random number as part of the directory hierarchy. Then messages that are processed multiple times will be retained in unique directory hierarchies

@media_dir = File.join(self.tmp_dir(),
                     Time.now.to_i.to_s,
                     self.safe_message_id(@mail.message_id))

or

@media_dir = File.join(self.tmp_dir(),
                     (rand(1e7)).to_s,
                     self.safe_message_id(@mail.message_id))

from mms2r.

kbaum avatar kbaum commented on July 1, 2024

I don't like using time since that could break in a multithreaded environment. I'm not sure of the specifics of the rand function but i know uuid is guaranteed to be unique.

  @media_dir = File.join(self.tmp_dir(),
                 "#{self.safe_message_id(@mail.message_id)}_#{UUIDTools::UUID.random_create}")

from mms2r.

monde avatar monde commented on July 1, 2024

I'm hesitant to bring in a dependency on the uuidtools gem (http://uuidtools.rubyforge.org/) into the main functionality of MMS2R to satisfy an somewhat edge case scenario in a testing environment.

from mms2r.

kbaum avatar kbaum commented on July 1, 2024

Makes sense. I would use an alternate method of generating a random unique string if I new it would always work. I have ran into issues in the past with rand methods that were based on time and not always that random.

I'm not too sure that you would never run into a scenario like this in multi-threaded environments. To me it just seems like we are making mms2r that much more bullet proof.

thx.

from mms2r.

monde avatar monde commented on July 1, 2024

In a threaded environment, given an app like Twitpic that posts MMS media to a feed, if the app starts processing the same message multiple times, then that's a flaw with the application, not with MMS2R. In a scenario like that, the app could work on each message using a work queue, or other similar methodology. MMS2R makes the assumption that each message is unique in terms of the value in its Message-ID header as can be seen in the logic to derive a temporary directory to decode all of its media.

To me, in a threaded testing environment that has no work queue, and is setting up and tearing down the same message fixture over and over, that 1:1,000,000 randomness is good enough. Such as:

@media_dir = File.join(self.tmp_dir(),
                     (rand(1e7)).to_s,
                     self.safe_message_id(@mail.message_id))

from mms2r.

kbaum avatar kbaum commented on July 1, 2024

Makes sense.

from mms2r.

monde avatar monde commented on July 1, 2024

I added your fork into the latest 2.4.0 version if you hadn't noticed, thanks

from mms2r.

Related Issues (16)

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.