[Home]

Summary:ASTERISK-24033: [patch]Extend STAT to check relative paths (for audio files)
Reporter:M vd S (mvds)Labels:
Date Opened:2014-07-12 07:28:59Date Closed:2014-09-10 17:32:18
Priority:TrivialRegression?
Status:Closed/CompleteComponents:Functions/func_env
Versions:Frequency of
Occurrence
Related
Issues:
Environment:anyAttachments:
Description:When playing sound files, I'd like to check existance *before* playing the file (i.e. not by checking Background() result or similar). I found STAT() to check file existance, but it only checks full paths. I think it would have "some extremely obvious (to many people) benefit" if STAT() would also understand relative paths like most sound/file-related functions do.

The way I solved it, with a minimum of files/lines changed, was to add this to funcs/func_env.c in stat_read(), line 286:
*\[EDIT: Inline code removed - mjordan\]*

(see diff below)

This is only a quick fix that only works for the e(xistance) check, and clearly doesn't recognize either "fmt" or "preflang" arguments to ast_fileexists().

The distinction between relative and absolute paths is very clear so I don't see a risk of breaking existing installations. To be on the extreme safe side, the return statement can also be conditional on the positive result of ast_fileexists().

I read the reasoning behind not allowing globbing in STAT (it was along the lines of "STAT() wraps the underlying stat() system call and should not do more"), which could also hold in this case, but I think most users would expect STAT to behave like other parts of Asterisk and allow relative filenames as well as absolute ones.

Diff against latest svn:

*\[EDIT: Inline code removed - mjordan\]*

Comments:By: Matt Jordan (mjordan) 2014-07-12 12:36:05.178-0500

While your idea and improvement sounds good, we cannot accept patches in descriptions or comments.

Please read the instructions for submitting a patch on the Asterisk wiki - [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Note that we do have a feature freeze for Asterisk 13 coming up on Wednesday, July 16th - if you'd like this improvement to get in for the next release, please make sure to post it up to review board for peer review. Instructions for doing this are also on the Asterisk wiki - [Code Review|https://wiki.asterisk.org/wiki/display/AST/Code+Review].



By: M vd S (mvds) 2014-07-12 14:31:20.604-0500

Thanks for the quick response, I'll try to submit a patch.

That is, after the Legal Department has accepted my license agreement...

By: Rusty Newton (rnewton) 2014-07-18 09:01:25.057-0500

[~mvds] Your license agreement appears to be processed and active. You can re-attach your patch and proceed with the code review process. Thanks!

By: Rusty Newton (rnewton) 2014-08-20 15:00:44.317-0500

[~mvds] I don't see a response from you. Did you have any further issue getting a patch attached?

By: Rusty Newton (rnewton) 2014-09-10 17:32:33.034-0500

Suspended due to lack of activity. Please request a bug marshal in #asterisk-bugs on the IRC network irc.freenode.net to reopen the issue should you have the additional information requested.  Further information can be found at http://www.asterisk.org/developers/bug-guidelines

Suspending this until the reporter is able to attach a patch and get the code on Reviewboard.