Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File mtime detected as invalid. #57

Closed
DaneEveritt opened this issue Oct 14, 2016 · 3 comments
Closed

File mtime detected as invalid. #57

DaneEveritt opened this issue Oct 14, 2016 · 3 comments

Comments

@DaneEveritt
Copy link
Contributor

DaneEveritt commented Oct 14, 2016

I'm having a strange issue where file uploads are being marked as having an invalid mtime when they are uploaded. This causes the files to use UNIX epoch as the timestamp (which is a bit undesirable).

This is an example of the output of the saved event on the server.

{ file: 
   { name: 'Microsoft Word - Lab 5 Lists.pdf',
     mtime: Invalid Date,
     encoding: 'octet',
     clientDetail: {},
     meta: { path: '', identifier: 'vqrn05pdn7m' },
     id: 0,
     size: 72118,
     bytesLoaded: 72118,
     success: true,
     base: 'Microsoft Word - Lab 5 Lists',
     pathName: '/srv/daemon-data/ptdl-mumble_e1ltb/data/Microsoft Word - Lab 5 Lists.pdf',
     writeStream: 
      WriteStream {
        _writableState: [Object],
        writable: true,
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        path: '/srv/daemon-data/ptdl-mumble_e1ltb/data/Microsoft Word - Lab 5 Lists.pdf',
        fd: 20,
        flags: 'w',
        mode: '0666',
        start: undefined,
        autoClose: true,
        pos: undefined,
        bytesWritten: 72118 } } }

Here is the output of event.file during the progress step in the browser.

lastModified: 1476111825000
meta: {path: "", identifier: "vqrn05pdn7m"}
name: "Microsoft Word - Lab 5 Lists.pdf"
size: 72118
type: "application/pdf"

Same output on the complete event in the browser.

lastModified: 1476111825000
meta: {path: "", identifier: "vqrn05pdn7m"}
name: "Microsoft Word - Lab 5 Lists.pdf"
size: 72118
type: "application/pdf"

Interestingly, if you refresh the page before the file is done uploading the last modified time is correct.

@DaneEveritt
Copy link
Contributor Author

Appears when the file is saved it shows up as this when you run ls -l:

-rw-r--r-- 1 user group  5987302 -9223372036854775808 Sea Turtles.docx

@vote539
Copy link
Collaborator

vote539 commented Oct 14, 2016

Interesting. SIOFU gets the mtime information from file.lastModifiedDate. However, according to MDN, "lastModifiedDate" is deprecated. I wonder if replacing "lastModifiedDate" with "lastModified" would fix the problem? On the server side, all that happens is that the value gets passed to a new Date() constructor.

Would you mind making this patch and see if it fixes your problem? Just go into client.js or client.min.js, search for "lastModifiedDate", and replace it with "lastModified". Thanks!

@DaneEveritt
Copy link
Contributor Author

Sure thing, I'll test that out later, and if it works I'll submit a PR.

DaneEveritt added a commit to DaneEveritt/socketio-file-upload that referenced this issue Oct 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants