Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delivery http does not clean temp file #441

Open
dazoot opened this issue Mar 2, 2025 · 2 comments
Open

delivery http does not clean temp file #441

dazoot opened this issue Mar 2, 2025 · 2 comments

Comments

@dazoot
Copy link
Contributor

dazoot commented Mar 2, 2025

If you change the delivery to http in a plugin, zone-mta creates a temp file with the posted body in /tmp but fails to clean it, and you end up with huge /tmp junk.

            delivery.http = true;
            delivery.targetUrl = "https://somehost/someurl";
@andris9
Copy link
Member

andris9 commented Mar 2, 2025

Well, this sounds strange, zone-mta should never write anything to disk 🤔

@dazoot
Copy link
Contributor Author

dazoot commented Mar 2, 2025

I think it actually comes from: formidable.

this.uploadDir = opts.uploadDir || (os.tmpdir && os.tmpdir()) || os.tmpDir();
IncomingForm.prototype._uploadPath = function(filename) {
  var buf = crypto.randomBytes(16);
  var name = 'upload_' + buf.toString('hex');

  if (this.keepExtensions) {
    var ext = path.extname(filename);
    ext     = ext.replace(/(\.[a-z0-9]+).*/i, '$1');

    name += ext;
  }

  return path.join(this.uploadDir, name);
};

So it's not from delivery.http but from adding an API endpoint to zonemta which gets file as body.

app.addAPI("POST", "/save", (req, res, next) =>  {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants