koltyakov / sppull

📎 Download files from SharePoint document libraries using Node.js without hassles
MIT License
46 stars 16 forks source link

SharePoint file status #45

Closed varunsree closed 4 years ago

varunsree commented 4 years ago

Is it possible to know the file status is Locked or not?

koltyakov commented 4 years ago

Hi @varunsree,

It should be possible by checking it in the usual for SP API way, which is not empty CheckoutUserId field value. For that purposes metaFields property can be used,

image

If not null then checked out.

varunsree commented 4 years ago

Thanks for your quick update. But I am facing an issue regarding the response. Always got null from the metadata response. I Mean always return null if the file is open/not

koltyakov commented 4 years ago

If a status is not affected in metadata obviously there is no way to track it at all. You can use the "require checkout to edit" option, but this is not connected with the library.

Just wondering, what scenario are you covering?

varunsree commented 4 years ago

Actually I want to update the SharePoint files at some point in time, So at that time, the file is opened in the browser I got the error message like 'File is Locked'. So I want to check that the file is opened before the update operation is performed.

koltyakov commented 4 years ago

Not sure that there is a way to understand if a file is locked before an update request sent and 423 HTTP Status code is received back, at least can't recall anything like this. Anyways, it should not be a part of documents fetching with SPPull (as time delay before a file is fetched and is locked to editing can be serious) but an update logic, relying on ETags, forcing checkouts while editing, etc. if a process involves many actors changing the docs.

koltyakov commented 4 years ago

Going to close this.