getFileInfo() is really slow

Description

this takes 188ms on an empty file with 5.3.5

ACF and Lucee 4.5 take 1ms

https://trycf.com/gist/f720c23b3fa9fd87dedf2f654025549a/lucee?theme=monokai

FileInfo() performs as expected

Environment

1.8.0_221 (Oracle Corporation) 64bit
Windows 10 (10.0) 64bit

Activity

Show:
Zac Spitzer
April 22, 2020, 6:48 PM

Doesn't NIO support reading these attributes since java 7, should be no need to spawn attrib?

KabutoTX
April 23, 2020, 1:15 AM
Edited

Yes. I forgot. DosFileAttributes supports Archive and System. isHidden() is already there.

I changed some code and it is now 0-4ms on Windows from ~90ms. Didn’t test on Linux.

What I don’t know is the correct way it should be implemented. You could change FileResource.java getAttribute() code to use DosFileAttributes instead of running attrib
OR
change the isArchive() and isSystem() overrides and get rid of the few getAttribute() calls. I don’t know why the others were deprecated in Resource.java to start using getAttribute().

There is a setAttribute() that is using attrib also that probably needs to be changed to NIO.

Zac Spitzer
April 23, 2020, 6:56 AM

nice work! can point you in the right direction

there’s also a few more ls command in the same file and a chmod just below it

KabutoTX
April 23, 2020, 8:28 PM

I submitted a pull request. I hope I did it right. I changes the getAttribute() and setAttribute() functions.

Michael Offner
April 24, 2020, 6:50 AM

pulled thanks for your work on this

Fixed

Assignee

Michael Offner

Reporter

Zac Spitzer

Priority

New

Fix versions

Sprint

None

Affects versions