Comments (9)
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.
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.
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.
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.
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.
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.
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.
Makes sense.
from mms2r.
I added your fork into the latest 2.4.0 version if you hadn't noticed, thanks
from mms2r.
Related Issues (16)
- Sprint UndefinedConversionError with ruby 1.9.2 HOT 1
- UTF-8 error with yahoo email HOT 1
- Certain characters in Outlook HTML emails are getting garbled. HOT 2
- deprecation warning on ruby 1.9.3 HOT 8
- Correct Handling of   in media['text/plain'] HOT 4
- MMS2R::Media filename? should strip HOT 2
- Verizon text messages aren't parsing properly HOT 5
- Sprint Messages aren't parsing HOT 2
- not mail gem compatible HOT 2
- Parsing Multipart bodies HOT 3
- undefined method `return_path' for #<TMail::Mail... HOT 4
- Problems with ruby 1.9.2 and rails3 HOT 4
- Mail/MMS2R HOT 3
- default_media is nil HOT 12
- mms2r 2.4.1/ Tmail and application/octet-stream HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mms2r.