-
Notifications
You must be signed in to change notification settings - Fork 197
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
Task.Folder can be null #871
Comments
If you have a task instance, and delete the folder to which it is assigned, my understanding is that all of the contained tasks and subfolders are also deleted. I believe the error you are seeing is that the Task should no longer be valid and not just the Parent property. In your described scenario, is the task instance still available from the system? This would be similar to getting a FileInfo instance for a file and then deleting the file from the system. You would still have a valid class instance but it does not represent a physical system instance. |
The Task is no longer valid as such, as it no longer exists, but Folder can return null then (which is incorrect with the attribute) . Alternatively, Folder could throw the original DirectoryNotFoundException. Throwing is probably better as some of the other properties also throw it, but would cause more things to be affected as GetFolder seems to be used in other places too. |
I think, given this scenario that I've never really accounted for, that I should review key functions and properties and ensure that they all throw an exception when trying to act on a folder or task that no longer exists. Doesn't that seem the appropriate behavior? |
I agree. Most properties of Task already throw a DirectoryNotFoundException if the folder is deleted. Some properties still work, such as the name, which is OK I guess. |
I'm considering putting in a simple method that I put in before any property is fetched that would check with TaskService to see if the task still exists and throw an exception if it was removed. Is that appropriate or too intrusive? |
For now, I check for null and throw a DirectoryNotFoundException exception if returned from GetFolder. After more investigation, and your feedback, I may still implement the more elaborate check for deleted tasks and folders. |
I think that's a good enough change for now. I haven't tried all properties but the ones I'm using already throw a DirectoryNotFoundException. |
Describe the bug
TaskScheduler/TaskService/Task.cs
Line 1086 in fbcee2e
This is marked as NotNull, but this is not correct. If you have a task and delete the folder it's contained in then Folder will return null.
See also:
TaskScheduler/TaskService/TaskService.cs
Line 663 in fbcee2e
To Reproduce
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: