-
Notifications
You must be signed in to change notification settings - Fork 179
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
Simply read File #166
Comments
Can you send a code sample of how you're calling the API's? And a full trace log Sent from my Samsung SM-G950F using FastHub |
This is how I get the file
and then I print file info:
Log trace is pretty short: |
Can you up the log level to |
There you go: 2017-08-24 15:45:25 DEBUG ProxySocketFactory:86 - Connecting to / |
I have no idea why the dates are getting changed. As you can see in the logging we only send It could be that we're reading the file dates in the wrong order, because I am pretty sure that when you open the file you change the last access time, which is the one that does not seem to be touched. But for that I would have to look into the specifications. |
Maybe somehow during that query file actually gets into 'Open' state... Do you have ideas how to overcome that problem? How about your File.getInputStream() method. Maybe If it was possible to instantiate FIle instance having SMB2FileId value - it would be possible to perform a simple read? - Is it possible to have File's constructor public and get File's SMB2FileId by some means? |
@hierynomus what triggers that query_info in the code? Afaict DiskShare#openFile shouldn't be doing that. @sshklianko from an SMB2 client perspective you're already doing just about everything you can: you're not sending any write requests at all and you're opening the file for read only usage. What you could try doing is sending a set info request with FileBasicInformation where you set the timestamp fields to the special FileBasicInformation#DONT_UPDATE values. That shouldn't even be necessary, but it might help. What type of server are you communicating with? Updating the last write/access/change time is a server side operation that you can't really control from the client side except with those special DONT_UPDATE(-1) and DONT_SET(0) values. If the server decides to still update the timestamps regardless of that there's not much you can do about it I'm afraid. |
The query_info is triggered by the fetch of File.getfileinformation(). But
that is also just a read op.
Op 24 aug. 2017 19:40 schreef "Pepijn Van Eeckhoudt" <
[email protected]>:
… @hierynomus <https://github.com/hierynomus> what triggers that query_info
in the code? Afaict DiskShare#openFile shouldn't be doing that.
@sshklianko <https://github.com/sshklianko> from an SMB2 client
perspective you're already doing just about everything you can: you're not
sending any write requests at all and you're opening the file for read only
usage. What you could try doing is sending a set info request with
FileBasicInformation where you set the timestamp fields to the special
FileBasicInformation#DONT_UPDATE values. That shouldn't even be
necessary, but it might help.
What type of server are you communicating with? Updating the last
write/access/change time is a server side operation that you can't really
control from the client side except with those special DONT_UPDATE(-1) and
DONT_SET(0) values. If the server decides to still update the timestamps
regardless of that there's not much you can do about it I'm afraid.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#166 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHLo96IWJ-EQKsuF-JQuyEb2cKPmq_Hks5sbbWFgaJpZM4PAqL9>
.
|
Thank you guys for your responses. @pepijnve Im using MS Server 2016. My intention is to be able to read the file and it's metadata, this is why it is important for me to not modify any file attributes, so I could use them. I will try the approach you propose. @hierynomus it should not be the server issue - when I use SMB1 protocol for the same purpose, file attributes are not modified. What is that packet SMB2_CREATE in the log? |
What you could check is which of the calls updates the timestamps. Is the time updated on the server if the But do that by checking on the server itself that you're connecting to. |
@hierynomus I've got an access to server and here is what I found: when I call DiskShare.openFile() - file gets completely erased. I believe it has to do with the fact it is really a file OPEN command - which prepares file for writing. So there is no problem with reading attributes - it just opens file as before write operation. Also, if you go to SMB2CreateRequest you'll see the SMB2MessageCommandCode.SMB2_CREATE message type being set. If I use DiskShare.list() operation - it gets me a correct file attributes, but I still need a way to do a simple file read. Can u advice on this? |
Hi stepan,
If that happens you're specifying the wrong create mode.
Op 25 aug. 2017 7:52 p.m. schreef "Stepan Shklianko" <
[email protected]>:
… @hierynomus <https://github.com/hierynomus> I've got an access to server
and here is what I found:
when I call DiskShare.openFile() - file gets completely erased. I believe
it has to do with the fact it is really a file OPEN command - which
prepares file for writing. So there is no problem with reading attributes -
it just opens file as before write operation. Also, if you go to
SMB2CreateRequest you'll see the SMB2MessageCommandCode.SMB2_CREATE
dialect being set.
If I use DiskShare.list() operation - it gets me a correct file
attributes, but I still need a way to do a simple file read. Can u advice
on this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#166 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHLo0Rky1894IuE77yaAIduefOeuGXJks5sbwnvgaJpZM4PAqL9>
.
|
Is there supposed to be any "create" mode for read operation? |
Smb2CreateDisposition.open will open the file without doing anything to it. Sent from my Samsung SM-G950F using FastHub |
That did the trick - I was able to read the file using Smb2CreateDisposition.open. Thanks @hierynomus One more question: is there a way to get a file size and file owner somehow from file attributes? |
The file size is in |
That's in the security descriptor which you can get using |
Ok, Thank you guys. I believe this ussue may be closed now. |
hi guys, can you tell me are you fixed problem with getting owner? |
If you want the SID literal (e.g., |
Regarding...
...I could not find the size there. Found it here instead:: |
Hi, @hierynomus .
Is there a possibility in your lib to read/download a file without affecting its attributes? Each call to DiskShare.openFile/getEntry results in file's change/write time attributes being set to current time
Thanks.
The text was updated successfully, but these errors were encountered: