Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix Move-Item with wildcard to non-existent destination flattening first directory#26604

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge14 commits intomaster
base:master
Choose a base branch
Loading
fromcopilot/fix-move-item-wildcard-issue
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
10ba694
Initial plan
CopilotDec 11, 2025
13cfcae
Fix Move-Item wildcard bug - preserve directory structure
CopilotDec 11, 2025
bd47771
Simplify fix by removing redundant parent existence check
CopilotDec 11, 2025
2c8a38c
Avoid duplicate ItemExists check by caching result
CopilotDec 11, 2025
c038b6e
Refactor to eliminate duplicate MakePath call
CopilotDec 11, 2025
59e273c
Revert "Refactor to eliminate duplicate MakePath call"
CopilotDec 11, 2025
98a08c2
Fix: Only treat non-existent destination as container when parent exists
CopilotDec 11, 2025
5369559
Fix wildcard move at SessionState level instead of provider
CopilotDec 11, 2025
e38c682
Fix: Use destination provider instance for creating destination direc…
CopilotDec 11, 2025
a3b381e
Fix: Use destinationContext and add null checks
CopilotDec 11, 2025
e9881be
Add verbose debug output to diagnose directory creation issue
CopilotDec 11, 2025
77f0817
Add -Verbose switch to test to enable diagnostic output
CopilotDec 11, 2025
9b18849
Fix wildcard move at cmdlet level instead of SessionState level
CopilotDec 11, 2025
758bc57
Fix compile error: Use correct signature for InvokeProvider.Item.New
CopilotDec 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Fix wildcard move at SessionState level instead of provider
The previous approach of fixing in FileSystemProvider broke single directory movesbecause it couldn't distinguish between wildcard moves and single directory renames.New approach: Fix at SessionState level where we know providerPaths.Count:- When moving multiple items (providerPaths.Count > 1) to non-existent destination,  create the destination directory first- This ensures all items preserve their names (fixes wildcard flattening bug)- Single item moves work normally (preserves rename behavior for cross-device test)This fixes the "Verify Move-Item across devices for directory" test failure.Co-authored-by: iSazonov <22290914+iSazonov@users.noreply.github.com>
  • Loading branch information
@iSazonov
Copilot andiSazonov committedDec 11, 2025
commit536955943bc66aebda935dc41d5bbc183e960f9d
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1502,6 +1502,27 @@ internal void MoveItem(
}
else
{
// When moving multiple items to a non-existent destination, create the
// destination directory first to ensure all items preserve their names.
// This prevents the first item from being renamed to the destination.
if (providerPaths.Count > 1 && providerDestinationPaths.Count == 0)
{
try
{
NewItemPrivate(
providerInstance,
destinationProviderInternalPath,
"Directory",
null,
context);
}
catch
{
// If creation fails (e.g., destination already exists due to race condition),
// continue with the move. The provider will handle any remaining errors.
}
}

foreach (string providerPath in providerPaths)
{
MoveItemPrivate(providerInstance, providerPath, destinationProviderInternalPath, context);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5838,27 +5838,11 @@ protected override void MoveItem(
// Get the DirectoryInfo
DirectoryInfo dir = new DirectoryInfo(path);

// Check destination existence once to avoid expensive duplicate check
bool destinationExists = ItemExists(destination);
if (destinationExists && IsItemContainer(destination))
if (ItemExists(destination) &&
IsItemContainer(destination))
{
destination = MakePath(destination, dir.Name);
}
else if (!destinationExists)
{
// When destination doesn't exist, check if parent exists to determine intent:
// - Parent exists: User wants to move into a new subdirectory (wildcard scenario)
// - Parent doesn't exist: User wants to rename/move to a new location
string parentPath = GetParentPath(destination, null);
if (!string.IsNullOrEmpty(parentPath) && ItemExists(parentPath) && IsItemContainer(parentPath))
{
// Parent exists and is a container, so treat destination as a new container
// This ensures consistent behavior when moving multiple items with wildcards.
CreateDirectory(destination, false);
destination = MakePath(destination, dir.Name);
}
// else: destination parent doesn't exist, treat as rename operation
}

// Don't allow moving a directory into itself or its sub-directory.
string pathWithoutEndingSeparator = Path.TrimEndingDirectorySeparator(path);
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp