Command hooks
Closed this issue · 4 comments
I'm opening this issue because:
- I have found a bug
- I want to request a feature
- I have a question
- Other
I think integrating command execution would be really convenient. Say you want to downsize a video and send it to your phone. Being able to run ffmpeg
would be really useful. Also, maybe people want to manipulate files from their phone as they arrive - some things are faster and better on the computer than on the phone.
How it would work
Send
- Each file is symlinked to its own space in
/tmp
- The commands are run concurrently on every file (replace
%
with the file name) - Once the command finishes, everything in its
/tmp
space is pushed to a stack of payloads - The stack is popped as it comes, and the files are served. (What should happen with the zip flag?)
Recieve
- The files are recieved into a
/tmp
space - The commands are run
- The files are copied into the current dir
What do you think? Integrating commands would make it much easier - running an ffmpeg
loop and then serving is slower, for example
Hi, thanks for this suggestion. While I'm not sure to fully understand what you have in mind, it doesn't seem to me something that should be implemented: qrcp
stands for "qr copy", any feature that is not strictly related to copying files from one end to another should be considered as out of scope. Nevertheless, if you could help me understand a real use case that your idea would cover, even using pseudo code, I could figure out if there is a way to integrate qrcp as is into a bash script or pipeline to implement the workflow.
Thanks!
The idea is an optimised way to perform time-consuming tasks on files such as downscaling. I understand why the previous idea could be out of scope. Here are some other ways:
- FIFO queue - the bash script can write the file names and they will be sent as they come, until the script writes a newline to the file
- Spawn - spawn a command, each new file created is sent.
qrcp
stops when the process finishes
For recieving, the /tmp way is not necessary. qrcp
doesn't need to see the files that are generated. A plain command plus a %
substitution suffices.
Ideally, less is within the command and more is within the script - and pushing to a FIFO queue is quite intuitive in my opinion.
For sending files as soon as they are created in /tmp
, what about something like:
inotifywait -m -e create --format '%w%f' /tmp | while read NEWFILE
do
qrcp $NEWFILE
done
?
I wasn't aware of that but I assume you could do something like it for downloads too. I can try it and add it to the docs if you want.