Reputation: 5195
I dynamically create folder with images in my public directory that looks something like this public/indiv/compa/ferfw432ervr12/test.png
. I want to delete the indiv
directory. I tried doing heroku run bash. and used rm
to delete the directory. I did ls
after and I could not find the file so I thought everything was good but I could still see the image when I go to the url so I did heroku run bash
and the files are still there. I want them gone.
I also did something like this:
var deleteFolderRecursive = function(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
It looks It deleted files from local but not heroku even after I did git push heroku master
Upvotes: 1
Views: 4209
Reputation: 5261
You need to understand how Heroku's ephemeral filesystem works.
Whatever files you push to Heroku exist in the filesystem of any and every dyno you run. It sounds like you have a web dyno that dynamically creates a directory with various image files. Probably not a very good idea on Heroku, unless you really only need those dynamically generated files to be available only to the dyno instance that created them, and only for the duration of that dyno instance's current cycle. It is highly unlikely that you have a use case that really justifies doing that, but let's say you do. Going in and doing a "heroku run bash" simply creates a new, "one off" dyno instance, which has its own ephemeral file system, that is completely separate from the ephemeral filesystem of your Web dyno. So, erasing a file or directory in your one-off dyno will have absolutely no impact on the behaviour of your web dyno.
Upvotes: 1