-
-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Enhance Folder.Clean() and CopyTo() methods with additional options #1693
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,9 +95,13 @@ | |
| /// <summary> | ||
| /// Removes all files and subdirectories within the folder. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This method preserves backward compatibility by not removing read-only attributes. | ||
| /// Use <see cref="Clean(bool)"/> with <c>removeReadOnlyAttribute: true</c> to handle read-only files. | ||
| /// </remarks> | ||
| public void Clean() | ||
| { | ||
| Clean(removeReadOnlyAttribute: true); | ||
| Clean(removeReadOnlyAttribute: false); | ||
| } | ||
|
Comment on lines
+98
to
105
|
||
|
|
||
| /// <summary> | ||
|
|
@@ -153,13 +157,15 @@ | |
| /// <returns>A new <see cref="Folder"/> instance representing the copied folder.</returns> | ||
| public Folder CopyTo(string targetPath, bool preserveTimestamps) | ||
| { | ||
| LogFolderOperationWithDestination("Copying Folder: {Source} > {Destination} [Module: {ModuleName}, Activity: {ActivityId}]", this, targetPath); | ||
|
|
||
|
Comment on lines
+160
to
+161
|
||
| Directory.CreateDirectory(targetPath); | ||
|
|
||
| // Copy all subdirectories first | ||
| foreach (var dirPath in Directory.EnumerateDirectories(this, "*", SearchOption.AllDirectories)) | ||
|
Check warning on line 165 in src/ModularPipelines/FileSystem/Folder.cs
|
||
| { | ||
| var sourceDir = new DirectoryInfo(dirPath); | ||
| var relativePath = System.IO.Path.GetRelativePath(this, dirPath); | ||
| var newPath = System.IO.Path.Combine(targetPath, relativePath); | ||
| var targetDir = Directory.CreateDirectory(newPath); | ||
|
|
||
|
|
@@ -206,8 +212,6 @@ | |
| targetRootDir.LastAccessTimeUtc = DirectoryInfo.LastAccessTimeUtc; | ||
| } | ||
|
|
||
| LogFolderOperationWithDestination("Copied Folder: {Source} > {Destination} [Module: {ModuleName}, Activity: {ActivityId}]", this, targetPath); | ||
|
|
||
| return new Folder(targetPath); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from
Clean(removeReadOnlyAttribute: true)toClean(removeReadOnlyAttribute: false)is a breaking change that contradicts both the PR description and the XML documentation. The PR states "removeReadOnlyAttribute=true" should be the default for "safe behavior," and the documentation claims to "preserve backward compatibility." However, the previous default wastrue, so changing it tofalsebreaks existing behavior. This will cause Clean() to fail on read-only files where it previously succeeded. Either revert totrueto maintain the stated goals, or acknowledge this is a breaking change and update the documentation accordingly.