API library update: files are kept in server library folder

Hi,

I’m using Xibo 1.8.1 CMS, running under Ubuntu 14.04 and docker. I’m trying to update an image to the library every 15 minute by calling the API. BUT, after the media is updated and the mediaId is incremented by one, the old file can still be found on the server library. I think it should be deleted given that the image was replaced with a new one. After running this update method every 15 minutes for couple of weeks I have thousands of old images in the server library folder, and those images are not shown as media in cms library (only the image that is being updated for each API call).

I’m using nodejs and the request module. I’m passing this options to the request call:

var options = {
    method: 'POST',
    url: baseURL + '/api/library',
    headers: {
        'cache-control': 'no-cache',
        authorization: 'Bearer ' + token
    },
    formData: {
        files: {
            value: fs.createReadStream(fileName + '.png'),
            options: {
                filename: fileName + '.png',
                contentType: null
            }
        },
        name: mediaName,
        oldMediaId: mediaId,
        updateInLayouts: 1,
        removeOldRevisions: 1
    }
};
request(options, function(error, response, body) {
    //Code here 
});

and I’m getting this reponse:

{
    "files": [{
        "name": "PBI_support",
        "size": 122084,
        "type": "image\/png",
        "url": "\/api\/library?file=PBI_support06-01_13-03.png&download=1",
        "mediaId": 2848,
        "storedas": "2848.png",
        "duration": 10,
        "retired": 0,
        "fileSize": 122084,
        "md5": "482cbc3489258577e991ad2bdeb16aba",
        "delete_url": "\/api\/library?file=PBI_support",
        "delete_type": "DELETE"
    }]
}

What I’m doing wrong? Any ideas?

Regards from Uruguay,
Germán

I had a look at my local CMS library and then at the code.

Which leads to one conclusion, the documentation is wrong it should be deleteOldRevisions not removeOldRevisions.

As removeOldRevisions does not exist in the code it does nothing, therefore all old revisions are still in the CMS library and the database.

My apologies that I did not see it earlier.

Just to confirm all parameters:

Thanks Peter, I tested with deleteOldRevisions and it fixed the problem! I will apply this solution to my production environment.

One thing we might face in the future and that concerns us: What is the maximum of mediaIDs that can be managed by the CMS? I mean, once I update a media the mediaID is increased by one, if I keep updating the media every few minutes, sooner or later this limit will be reached.

I imagine that this is determined by mysql’s int data type limit, which according mysql docs is 2147483647, then this limit would not be a problem at all.

Should we pay any special attention on this potential issue?

Thanks for your help and quick responses!
Br.