Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8407885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:29:31+00:00 2026-06-09T23:29:31+00:00

I use the uptodate? method in Ruby to determine if a file must be

  • 0

I use the uptodate? method in Ruby to determine if a file must be re-compiled/re-linked /re-generated etc. Sometimes the build framework I use is so fast at these steps that the output file and the prerequisite file have the exact same file modification timestamps. This causes the build framework to re-compile/re-link files unnecessarily.

I compare timestamps for building like so –

compile_file(file) unless uptodate?(file, %W(#{dependencies}))

I looked up the source for uptodate? from here and it looks like this –

def uptodate?(new, old_list, options = nil)
  raise ArgumentError, 'uptodate? does not accept any option' if options
  return false unless File.exist?(new)
  new_time = File.mtime(new)
  old_list.each do |old|
    if File.exist?(old)
      return false unless new_time > File.mtime(old)
    end
  end
  true
end

As suspected, it returns false if the timestamps are equal. What’s the most elegant way to get around this issue? I have tried running the framework on Linux and Windows and I have the same problem. From what I read here it’s unlikely to be a file system specific file modification time resolution issue (since ext4 has a resolution of 1 microsecond).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:29:33+00:00Added an answer on June 9, 2026 at 11:29 pm

    uptodate? seems correct. If the timestamps are equal, the file may be up to date, or it may not. Therefore it errs on the safe side and declares it out of date.

    In the steps where you build files, add logic to advance the time by the built file by a second if it is equal to the time of its dependency. Yes, it’s a hack, but might be the best you can do under the circumstances.

    Some file systems (ext4, etc.) can store timestamps with sub-second resolution and might be worth looking at.

    Barring any of the above, you can either monkey-patch uptodate? or just create your own that errs on the side of not-building when the timestamps are equal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use case: 3rd party application wants to programatically monitor a text file being generated
use C#,want to upload excel file on google doc. bellow syntax use to upload
use javascript or other method ? have any recommendation?
use warnings; use Test::More; use File::Find::Rule; use Test::File::Find::Rule; my $rule = File::Find::Rule->file->name('*.pl')->not_grep(qr/^\s*use\s+strict;/m, sub {
use Image::Imlib2; my $a = Image::Imlib2->load(/foo/file); gives me the following error: Runtime error: Image::Imlib2
use a reapeter to display data, but sometimes the data is to big to
Use Case Show a photo uploaded by the user in a square box with
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
use strict; use warnings; use Time::HiRes qw(sleep); use Test::WWW::Selenium; use Test::More no_plan; use Test::Exception;
use the [] symbol in the name of the form field you are submitting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.