Page 1 of 1

Error while purging trash

PostPosted:Wed Feb 15, 2017 7:05 pm
by openkm_user
Hi,

We have around 10,000 documents in Trash which we are trying to Purge, under username there are 60 folder each folder containing 200 folders inside, in which there are documents ranging from 1 to 50 documents.

-username
--folder1
---innerfolder1
----document1
----document2
----***
----***
----documentn
---innerfolder2
---innerfolder3
---***
---***
---innerfolder200
--folder2
--folder3
--***
--***
--folder60

When I try to Purge it does not delete anything and keeps returning the following errors,
okm_trash_db_error.JPG
okm_trash_db_error.JPG (20.11 KiB) Viewed 1456 times
okm_trash_db_error_n.JPG
okm_trash_db_error_n.JPG (22.16 KiB) Viewed 1456 times
We are able to delete innerfolders if we tried to do so, seems like a problem if done in bulks.

Is there any other way to Purge Trash? Please advice!

Re: Error while purging trash

PostPosted:Fri Feb 17, 2017 11:21 am
by jllort
The problem in community version while purge files is that all is still done in a single database transaction. That has been corrected in professional.

The problem could be is raising SQL exception what stops the process or similar thing and you are not seeing the real error. Anyway the best option I can offering you is script to iterate along all the folders and then purge step by step.
Code: Select all
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.openkm.api.*;
import com.openkm.bean.*;
 
Logger log = LoggerFactory.getLogger("com.openkm.scripting");
int MAX_DEPTH = Integer.MAX_VALUE;
 
void nodeTask(String path, int depth) throws Exception {
    for (Document doc : OKMDocument.getInstance().getChildren(null, path)) {
        log.info("Document: {}", doc.getPath());
        // Here purge the document one by one
    }
 
    for (Folder fld : OKMFolder.getInstance().getChildren(null, path)) {
        log.info("Folder: {}", fld.getPath());
 
        if (depth < MAX_DEPTH) {
            nodeTask(fld.getPath(), depth + 1);
        }
    }
}
 
log.info("***** Process BEGIN *****");
nodeTask("/okm:trash", 0);
log.info("***** Process END *****");