Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Artifactory AQL delete empty folders

How do I delete empty folders(folders without any content) by using Artifactory AQL?

I have the current AQL query to find files that are older than 12w and never downloaded, which I will delete by an script.

items.find(
    {
        "repo":{"$eq":"libs-release-local"},
        "stat.downloads":{"$eq":null},
        "created":{"$before" : "12w"},
    }
)

This leaves me with empty folders, how do I specify an AQL query that finds all empty folders?

like image 630
ki_ Avatar asked Nov 18 '16 07:11

ki_


1 Answers

From Artifactory Query Language documentation: if type is not specified in the query, the default type searched for is file.

By adding a type to the query you can control the result type: file, folder or both.

For example:

items.find(
    {
        "repo": {"$eq":"libs-release-local"},
        "stat.downloads": {"$eq":null},
        "created": {"$before" : "12w"},
        "type": {"$eq":"any"}
    }
)
like image 104
Roman G Avatar answered Sep 21 '22 03:09

Roman G