FileVersion.IsCurrentVersion is never true
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 259
- Forks
- 161
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
Hi,
I created a console app to delete old versions (excluding the current version and versions newer than 3 months ago).
The code is:
var file = ctx.Web.GetFileById((Guid)item["UniqueId"]);
ctx.Load(file);
ctx.Load(file.Versions);
ctx.ExecuteQueryRetry();
var lstVersionsToDelete = file.Versions.Where(v => !v.IsCurrentVersion && v.Created <= DateTime.Now.AddMonths(-3)).ToList();
var lstVersion = lstVersionsToDelete.ToList();
foreach (var version in lstVersion)
{
version.DeleteObject();
}
ctx.ExecuteQueryRetry();
But sometimes I get an error "You cannot delete the current version"!
After investigation it seems the IsCurrentVersion property is never set to true.
Could this be an issue with the framework?
Thanks.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported console-app example using FileVersion.IsCurrentVersion, file.Versions, and ExecuteQueryRetry. Reproduce the version-deletion error and inspect whether IsCurrentVersion is populated correctly for the current item in the loaded collection. Done means the current version is reliably identified and the deletion loop no longer attempts to delete it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100