Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_file.py @ 3528:849374e59178
component file sharing: quotas implementation:
quotas can now be specified using the `quotas_json` option of `component file_sharing`
section in settings. This must be a dict where:
- `users` key contains default quotas for all users
- `admins` key contains quotas for administrators (not implemented yet)
- `jids` contain bare JID to quota mapping, to have user-specific quota
The value can be either a int for quota in bytes, or a case insensitive string with an
optional multiplier symbol (e.g. "500 Mio"). `None` can be used for explicit unlimited
quota (which is the default is `users` is not set).
When a file size is too big for quota, upload is refused with an error message indicating
allowed quota, used space, and the size of the file that user wants to upload.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 05 May 2021 15:37:33 +0200 |
parents | 584379473925 |
children | ca980569318c |
comparison
equal
deleted
inserted
replaced
3527:bbf92ef05f38 | 3528:849374e59178 |
---|---|
264 self.openFileWrite( | 264 self.openFileWrite( |
265 client, file_path, transfer_data, file_data, stream_object | 265 client, file_path, transfer_data, file_data, stream_object |
266 ) | 266 ) |
267 return True | 267 return True |
268 else: | 268 else: |
269 return self.getDestDir(client, peer_jid, transfer_data, file_data) | 269 return defer.ensureDeferred( |
270 self.getDestDir(client, peer_jid, transfer_data, file_data) | |
271 ) | |
270 | 272 |
271 exists_d = xml_tools.deferConfirm( | 273 exists_d = xml_tools.deferConfirm( |
272 self.host, | 274 self.host, |
273 _(CONFIRM_OVERWRITE).format(file_path), | 275 _(CONFIRM_OVERWRITE).format(file_path), |
274 _(CONFIRM_OVERWRITE_TITLE), | 276 _(CONFIRM_OVERWRITE_TITLE), |
284 return exists_d | 286 return exists_d |
285 | 287 |
286 self.openFileWrite(client, file_path, transfer_data, file_data, stream_object) | 288 self.openFileWrite(client, file_path, transfer_data, file_data, stream_object) |
287 return True | 289 return True |
288 | 290 |
289 def getDestDir(self, client, peer_jid, transfer_data, file_data, stream_object=False): | 291 async def getDestDir( |
292 self, client, peer_jid, transfer_data, file_data, stream_object=False | |
293 ): | |
290 """Request confirmation and destination dir to user | 294 """Request confirmation and destination dir to user |
291 | 295 |
292 Overwrite confirmation is managed. | 296 Overwrite confirmation is managed. |
293 if transfer is confirmed, 'file_obj' is added to transfer_data | 297 if transfer is confirmed, 'file_obj' is added to transfer_data |
294 @param peer_jid(jid.JID): jid of the file sender | 298 @param peer_jid(jid.JID): jid of the file sender |
311 "size_human" will also be added with human readable file size | 315 "size_human" will also be added with human readable file size |
312 @param stream_object(bool): if True, a stream_object will be used instead of file_obj | 316 @param stream_object(bool): if True, a stream_object will be used instead of file_obj |
313 a stream.FileStreamObject will be used | 317 a stream.FileStreamObject will be used |
314 return (defer.Deferred): True if transfer is accepted | 318 return (defer.Deferred): True if transfer is accepted |
315 """ | 319 """ |
316 cont, ret_value = self.host.trigger.returnPoint( | 320 cont, ret_value = await self.host.trigger.asyncReturnPoint( |
317 "FILE_getDestDir", client, peer_jid, transfer_data, file_data, stream_object | 321 "FILE_getDestDir", client, peer_jid, transfer_data, file_data, stream_object |
318 ) | 322 ) |
319 if not cont: | 323 if not cont: |
320 return ret_value | 324 return ret_value |
321 filename = file_data["name"] | 325 filename = file_data["name"] |