How to correctly delete dirs that have \ in path/name - Raw hosted repo

Hi,

What is the correct way to delete incorrectly added dirs with \ in path name in RAW hosted repo type on Nexus-3 (v3.23.0-03)?

For example something\something\something uploaded by error with pasting paths by uploading components from old location. Dir just refuses to be deleted if using “Delete folder” in web interface.

This is a known issue, see here for workarounds: https://issues.sonatype.org/browse/NEXUS-21107

Thanks for reply.

That Issue does not seem to be publicly viewable. Did try to find it by manually browsing NEXUS project also.

Do I need to create/register an account on https://issues.sonatype.org/ jira instance in order to view it?

Sorry about that, you should be able to see it now.

Rich

Thanks, I can now access the issue.

First workaround I can’t really try as if backslahed dir is uploaded no files are actually stored in this dir. Or at least system does not show it. Also when trying to query it via REST query no assets are shown.

Second workaround with groovy script does not work with backslashed dirs it seems.

Tried dir name strings:

  • test\\test\\test
  • test\test\test
import org.sonatype.nexus.repository.maintenance.MaintenanceService;

repo = repository.getRepositoryManager().get("files")
MaintenanceService maintenanceService = container.lookup(MaintenanceService.class.name)
maintenanceService.deleteFolder(repo, "test\\test\\test")

Script did work fine for deleting dir with space in it’s name, but not with backslash.

Maybe I am just missing something in Groovy formatting? Haven’t really used Groovy before this.

I had a folder with some \ characters in the name and wasn’t able to delete it until I uploaded a new file to that same path, this converted the “folder” into an “asset” which gave me a button to “Delete Asset”. This was with version 3.27.0-03

I had…
root_dir/intermediate_dir/bad\ dir\ name

So I uploaded a new file named intermediate_dir to root_dir and then was able to delete the intermediate_dir asset.