I’m simply trying to move a bunch of assets from one folder to another inside a commandlet. I’ve initialized the source control module and checked to ensure that it’s enabled (and all the perforce details in the log appear to be correct)
I do it something like this:
FAssetRenameData RenameData(asset, TargetPackagePath, asset->GetName());
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
IAssetTools& AssetTools = AssetToolsModule.Get();
AssetTools.RenameAssets({RenameData});
The source file gets checked out (not marked for delete), the destination file gets created, but not marked for add.
The log also has some interesting lines:
FAssetRenameManager::AutoCheckOut: was not not able to auto checkout.This seems to happen despite the checkout succeeding?
SourceControl: Error: CommandMessage Command: Copy, Error: Can't clobber writable file D:\path\to\asset.uasset
Error: CommandMessage Command: Copy, Error: D:\path\to\asset.uasset - no file(s) to resolve.
This error is about the local file at the target location that it literally just created
Were there maybe some bugs in 5.4 that have been fixed in later versions, or is there some trick to using the function (or am I just making a big, obvious mistake somewhere)?
EDIT 26/05:
OK it looks like there are two problems here:
1 - This one is just a bit of a spurious error message:
Inside `FAssetRenameManager::AutoCheckOut`, the “success” code path spews out `LogAssetTools: Warning: FAssetRenameManager::AutoCheckOut: was not not able to auto checkout.` - basically, we have a warning, and a message with a double negative. I think this should be changed to “Display” (from “Warning”) and the message should probably be something like “Successfully checked out package %s”
2 - This is the more serious problem:
Inside `UEditorEngine::IsPackageValidForAutoAdding`, for some unexplained reason, you prevent commandlets from adding assets to source control (which also, unfortunately, includes moving and copying files) with a simple `!IsRunningCommandlet()` check. I commented out that part of the condition and my commandlet magically started working.
Why is it like this? Can we remove this check? Is this fixed in a more recent version of unreal?