Skip to content

atime is not set when passing a Date as the documentation says #31

Description

@aalexgabi

In onopen:

  onopen (er, fd) {
    if (er) {
      if (er.code === 'EISDIR')
        this.onopen(null, null)
      else if (er.code === 'ENOENT' && this.nocreate)
        this.emit('done')
      else
        this.emit('error', er)
    } else {
      this.fd = fd
      if (this.ref)
        this.statref()
      else if (!this.atime || !this.mtime)
        this.fstat()
      else
        this.futimes()
    }
  }

In onfstat:

  onfstat (st) {
    if (typeof this.atime !== 'number')
      this.atime = parseInt(st.atime.getTime()/1000, 10)

    if (typeof this.mtime !== 'number')
      this.mtime = parseInt(st.mtime.getTime()/1000, 10)

    this.futimes()
  }

If atime or mtime is missing stat is called:

      else if (!this.atime || !this.mtime)
        this.fstat()

In the stat callback onstat if atime is not number it is overwritten with the value returned by stat:

    if (typeof this.atime !== 'number')
      this.atime = parseInt(st.atime.getTime()/1000, 10)

The doc says atime should be a date not a number

atime like touch -a Can be either a Boolean, or a Date.

The doc is wrong but this causes a bug that is hard to debug.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions