46 Commits

Author SHA1 Message Date
Arksine
6763ea6197 file_manager: correct issue with directories that contain spaces
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-13 05:25:37 -05:00
Arksine
697be6a822 file_manager: Immedately fetch metadata for file uploads
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-12 17:27:52 -05:00
Arksine
27a17ed5a6 file_manager: update request handlers to accept WebRequest objects
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-11 04:46:21 -05:00
Arksine
453745c1b6 file_manager: rename references from "url_path" to "rel_path"
This is a better description of the item parsed from _convert_path() is a path relative to the "root" directory.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-08 07:39:59 -05:00
Arksine
ffdcfd527a file_manager: clear metadata on item delete or move
When a directory is deleted or moved go ahead and prune the storage.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-08 07:39:36 -05:00
Arksine
472c7c4b23 file_manager: rename all refrences of "base" to "root"
Previously different parts of the file manager referred to name identifying a "root directory" as either base or root.  This could lead to confusion, so all references are now "root".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-07 20:36:08 -05:00
Arksine
c415f9ee15 file_manager: Don't store file lists
Since we need to walk through a file list each time one is requested there is no gain from storing lists locally.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-07 20:36:08 -05:00
Arksine
e51dbb45c1 file_manager: refactor the MetadataStorage class
Storage is now updated by individual calls to "parse_metadata()" instead of passing a full list.  This will allow the manager to

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-07 20:36:08 -05:00
Arksine
8bd6e45303 file_manager: fix bug in _handle_metadata_request()
Don't modify the metadata directly.  Create a copy, then add the "filename" item.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-05 12:43:17 -05:00
Arksine
624be50026 file_manager: add "extended" argument to directory endpoint
If extended==True is passed to GET directory then the result for each gcode file will include associate metadata, if present.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-02 20:18:07 -05:00
Arksine
f14b1f3ff0 file_manager: use os.path.splitext to find file extensions
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-11-02 20:18:03 -05:00
Arksine
0d515e4938 file_manager: Add support for uploading and extracting ufp files
Credit to GitHub user cdkeito for creating a template from which this implementation was inspired.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-10-31 08:40:49 -04:00
Arksine
f2fb8d33d4 file_manager: store file "modified" time as unix time
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-10-21 17:53:08 -04:00
Arksine
264e708c1d file_manager: fix typo in directory check
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-10-05 18:16:10 -04:00
Arksine
620fb356cc file_manager: Update the internal file list when get_directory is called
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-10-05 17:57:18 -04:00
Arksine
36c82d0c7f file_manager: simplify directory registration
Now that the file_manager directly  handles DELETE file requests, it is not necessary have the HTTP file handler perform any checks.   Thus it is no longer required to pass a "can_delete" parameter.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-09-07 12:38:15 -04:00
Arksine
ae49dfe8f2 file_manager: add websocket method for file delete
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-09-07 12:38:15 -04:00
Arksine
7078d5c980 file_manager: update delete_file method
This method is now the primary means of deleting files, as it includes checks to make sure that the delete is allowed.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-09-07 12:38:15 -04:00
Arksine
371c15aa33 file_manager: update API registration
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-09-03 14:01:34 -04:00
Arksine
2a34986acb file_manager: check for unsuccessful attempt at metadata extraction
If the metadata script encoutners an error it will return an empty dict for the "metadata" item.  Do not update the metadata storage or send a notification if the dict is empty.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-09-02 17:13:25 -04:00
Arksine
304e861a28 file_manager: refactor metadata extraction
Move logic for managine metadata to its own class.  Allow 3 retries if extraction fails, and send a printer event if metadata is updated due to an added file.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-30 15:28:21 -04:00
Arksine
4a57dba586 moonraker: update protocol for data received from klippy
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-15 14:19:19 -04:00
Arksine
43b057c40c moonraker: klippy requests no longer take a "request method"
Klippy rpc methods now accept either GET or POST, the method will be executed.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-15 08:38:06 -04:00
Arksine
a7147a44ca moonraker: refactor "make_request"
The make_request() method is now awaitable and returns the result directly vs the previous behavior of returning a request that was awaited.

There is no longer a need to check the result to see if it is an error, exceptions are raised if an error is detected.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-12 08:43:37 -04:00
Arksine
2c332a968f file_manager: require base paths be located within home directory
They however cannot be the home directory.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 20:34:20 -04:00
Arksine
7cd22804dd moonraker: replace legacy string interpolation with f-strings
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 14:28:41 -04:00
Arksine
7441da4b57 file_manager: refactor notify_filelist_changed()
This brings more consistency to the notification.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 14:21:27 -04:00
Arksine
b92000dd46 moonraker: Use file_manager to update mutable endpoints
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 08:38:28 -04:00
Arksine
98b3c990e0 file_manager: Add configparser support
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 08:38:27 -04:00
Arksine
9c76875896 file_manager: use print_stats to determine if an operation is safe
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-05 14:02:06 -04:00
Arksine
43d54f078e file_manager: Restrict full access to "gcodes" and "config" paths
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-05 11:05:55 -04:00
Arksine
d572a13655 file_manager: refactor config file handling
Remove the "primary_config" option from the upload handler, as we no longer allow writes to printer.cfg unless it is located in the config path.  We now assume that the config path is the main config, so all files there are located at  /server/files/config/*.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-05 11:05:00 -04:00
Arksine
f0e388ccdc file_manager: Add support for config examples
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-01 06:05:19 -04:00
Arksine
b6f8ba775c file_manager: implement file_list_changed notifcation
This notification is moved from moonraker.py.  Instead of sending a filelist, it now updates the file list and sends all relevant information to the client.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-01 06:05:19 -04:00
Arksine
e0fb261c12 file_manager: refactor upload logic
Break gcode and config file uploads into their own functions.  Add a 'primary_config' argument to config file uploads.  If set to true, the upload will overwrite printer.cfg.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-01 06:05:19 -04:00
Arksine
8b5c8786b4 file_manager: Verify that uploads are not written to folders outside of the "base" directory
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-01 06:05:19 -04:00
Arksine
9743772b45 file_manager: Add support for configuration files
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-01 06:05:19 -04:00
Arksine
bf1a666e20 file_manager: Allow the self.file_paths to contain paths to files
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-01 06:05:19 -04:00
Arksine
f0fa1295a7 file_manager: handle file upload processing
This implentation allows for uploads to different local paths by specifying a "root" argument in the form.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-01 06:05:19 -04:00
Arksine
879ddea0e5 file_manager: quote file name passed to metadata process
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-14 07:49:08 -04:00
Arksine
1d1edf33c3 file_manager: Use sys.executable to identify python env
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-14 07:39:05 -04:00
Arksine
6c58bba8c5 file_manager: Add debug logging to metadata response
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-14 07:22:19 -04:00
Arksine
29e7df38d0 file_manager: Add move and copy APIs
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-14 07:00:52 -04:00
Arksine
5754609203 file_manager: reject requests to delete a "root" directory
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-04 15:22:08 -04:00
Arksine
0e79b6f3f7 file_manager: add JSON-RPC "directory" APIs
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-04 14:33:17 -04:00
Arksine
d1c740b900 moonraker: add initial source
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-02 12:24:15 -04:00