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

Unable to load IFileVersion.Size property for items 2GB and greater #581

Closed
1 task done
WillickDN opened this issue Oct 14, 2021 · 6 comments
Closed
1 task done
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@WillickDN
Copy link

Category

  • Bug

Describe the bug

For context, the IFile.Length is of type long and IFileVersion.Size if of type int. Both of them are supposed to return the size of the file (or its version) from Sharepoint. Any FileVersion that is larger than an int can hold won't load the .Size property and trying to load it will throw an exception.

Steps to reproduce

var listItem = await list.Items.GetByIdAsync(1, li => li.All, li => li.Versions.QueryProperties(v => v.All, v => v.FileVersion.QueryProperties(fv => fv.Size)), li => li.File);
//Can't be the current version, as that is just the IFile to handle content, not IFileVersion.
var version = listItem.Versions.AsRequested().FirstOrDefault(v => !v.IsCurrentVersion);
if (version != null) { var size = version.FileVersion.Size; Console.WriteLine($"Size in bytes is {size}"); }

  1. See code in case it's just me.
  2. Load a ListItem and its versions, as well as the fileVersion.Size property.
  3. Try on a fileVersion smaller than 2GB, it works and prints the size
  4. Try again on a fileVersion that is larger than 2GB, it throws an exception.

{HttpResponseCode: 400
Code: System.InvalidOperationException
Message: Operation is not valid due to the current state of the object.
ClientRequestId:
} PnP.Core.BaseError {PnP.Core.SharePointRestError}

Expected behavior

Should be able to load the Size property of file versions that are larger than 2GB.

Environment details (development & target environment)

  • SDK version: [1.4.0 ]
  • OS: [Windows 10]
  • SDK used in: [ Console App]
  • Framework: [ .NET Core v3.x ]
  • Tooling: [Visual Studio 2019]
@jansenbe jansenbe self-assigned this Oct 15, 2021
@jansenbe jansenbe added area: model 📐 Related to the core SDK models bug Something isn't working labels Oct 15, 2021
@jansenbe
Copy link
Contributor

Nice catch @WillickDN , I've updated that property to also be a long. Please check our next nightly build for the update.

Thanks for using PnP Core SDK and providing this feedback!

@WillickDN
Copy link
Author

Thanks for getting to this so quick!

I pulled in the latest today, 1.4.16-nightly. I can see that the type of IFileVersion.Size is a now a long (confirmed in my testing).

However, it still fails to load the property if the size of the versions content is greater than 2147483647 bytes.

This line:
var listItemCheck = await list.PnpList.Items.GetByIdAsync(1, li => li.All, li => li.Versions.QueryProperties(v => v.All, v => v.FileVersion.QueryProperties(fv => fv.Id, fv => fv.Size)), li => li.File.QueryProperties(f => f.Length));
throws the exception:

PnP.Core.Services.BatchClient.ProcessSharePointRestBatchResponseContent(PnP.Core.Services.Batch, string)
PnP.Core.Services.BatchClient.ProcessSharePointRestBatchResponse(PnP.Core.Services.BatchClient.SPORestBatch, string)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs
PnP.Core.Services.BatchClient.ExecuteSharePointRestBatchAsync(PnP.Core.Services.Batch)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs
PnP.Core.Services.BatchClient.ExecuteBatch(PnP.Core.Services.Batch)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs

If I only request the files length for any size file, it will return the file.Length property no problem.

Again, thanks for looking at it. If you need more information I can try and get it for you.

@jansenbe
Copy link
Contributor

jansenbe commented Oct 18, 2021

Let me build a test case and see if I can repro/fix this @WillickDN

jansenbe added a commit that referenced this issue Oct 18, 2021
@jansenbe
Copy link
Contributor

@WillickDN : managed to repro and fix this. The issue was because the Size property on SP.FileVersion was an Int32 (see https://s-kainet.github.io/sp-rest-explorer/#/entity/SP.FileVersion). Luckily there was also a Length property which is Int64, which now has been mapped as SharePoint property for the Size property in PnP Core. Please try again with the next nightly.

@WillickDN
Copy link
Author

Awesome find!

I will grab the next nightly and try again.

Thank you!

@WillickDN
Copy link
Author

Grabbed the latest nightly and looks like the issue is taken care of.

Thanks again for everything you are doing. Really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants