We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add an option to run a task for free_space, besides abort. 
<!---
Before opening an issue, verify:

- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget
- Is this an issue with webui? Make an issue over on https://github.com/Flexget/webui
- Did you recently upgrade? Look at the Change Log and Upgrade Actions to make sure that you don't need to make any changes to your config https://flexget.com/ChangeLog https://flexget.com/UpgradeActions
- Are you running FlexGet as a daemon? Stop it completely and then start it again https://flexget.com/CLI/daemon
- Did you search to see if the issue already exists? https://github.com/Flexget/Flexget/issues
- Did you fill out the issue template as completely as possible?

The issue template is here because it helps to ensure you submitted all the necessary information the first time, and allows us to more quickly review issues. Please fill it out correctly and do not ignore it, no matter how irrelevant you think it may be. Thanks in advance for your help with this!
--->

### Expected behaviour:

Run the task when free_space on a given drive is getting low. 

It is useful when we clean the old seeds, movies, etc...

### Actual behaviour:

For now, it will always abort.

### Steps to reproduce:
Normal configuration.

#### Config:
```yaml
  clean.check_free_space:
    priority: 9
    free_space:
      path: /mnt/Disk1/Downloads
      space: 30000
    mock: [{title: "Check.Free.Space"}]
    accept_all: yes
    exec: echo "Check free space."
    disable: [seen]
    run_task:
      when: aborted
      task: purge.finished_seeds

  purge.finished_seeds:
    limit_new: 2
    <<: *from_transmission
    if:
      - transmission_progress != 100.0: reject
    <<: *clean_transmission
```
  
#### Log:
<details>
 <summary>(click to expand)</summary>

```
No need
```
</details>

### Additional information:

- FlexGet version: latest
- Python version: 
- Installation method: docker/wiserain
- Using daemon (yes/no):
- OS and version:
- Link to crash log:

<!---
In config and debug/crash logs, remember to redact any personal or sensitive information such as passwords, API keys, private URLs and so on.

Please verify that the following data is present before submitting your issue:

- Link to a paste service or paste above the relevant config (preferably full config, including templates if present). Please make sure the paste does not expire, if possible.
- Link to a paste service or paste above debug-level logs of the relevant task/s (use `flexget -L debug execute --tasks <Task_name>`).
- FlexGet version (use `flexget -V` to get it).
- Full Python version, for example `2.7.11` (use `python -V` to get it). 
- Installation method (pip, git install, etc).
- Whether or not you're running FlexGet as a daemon.
- OS and version.
- Attach crash log if one was generated, in addition to the debug-level log. It can be found in the directory with your config file.
--->


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `flexget/plugins/operate/free_space.py`
Content:
```
1 import os
2 
3 from loguru import logger
4 
5 from flexget import plugin
6 from flexget.event import event
7 
8 logger = logger.bind(name='free_space')
9 
10 
11 def get_free_space(config, task):
12     """Return folder/drive free space (in megabytes)"""
13     if 'host' in config:
14         import paramiko
15 
16         ssh = paramiko.SSHClient()
17         ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
18         try:
19             ssh.connect(
20                 config['host'],
21                 config['port'],
22                 config['user'],
23                 config['ssh_key_filepath'],
24                 timeout=5000,
25             )
26         except Exception as e:
27             logger.error("Issue connecting to remote host. {}", e)
28             task.abort('Error with remote host.')
29         if config['allotment'] != -1:
30             stdin, stdout, stderr = ssh.exec_command(f"du -s {config['path']} | cut -f 1")
31         else:
32             stdin, stdout, stderr = ssh.exec_command(
33                 f"df -k {config['path']} | tail -1 | tr -s ' ' | cut -d' ' -f4"
34             )
35         outlines = stdout.readlines()
36         resp = ''.join(outlines)
37         ssh.close()
38         try:
39             if config['allotment'] != -1:
40                 free = int(config['allotment']) - ((int(resp.strip()) * 1024) / 1000000)
41             else:
42                 free = int(resp.strip()) / 1000
43         except ValueError:
44             logger.error('Non-integer was returned when calculating disk usage.')
45             task.abort('Error with remote host.')
46         return free
47     elif os.name == 'nt':
48         import ctypes
49 
50         free_bytes = ctypes.c_ulonglong(0)
51         ctypes.windll.kernel32.GetDiskFreeSpaceExW(
52             ctypes.c_wchar_p(config['path']), None, None, ctypes.pointer(free_bytes)
53         )
54         return free_bytes.value / (1024 * 1024)
55     else:
56         stats = os.statvfs(config['path'])
57         return (stats.f_bavail * stats.f_frsize) / (1024 * 1024)
58 
59 
60 class PluginFreeSpace:
61     """Aborts a task if an entry is accepted and there is less than a certain amount of space free on a drive."""
62 
63     schema = {
64         'oneOf': [
65             {'type': 'number'},
66             {
67                 'type': 'object',
68                 'properties': {
69                     'space': {'type': 'number'},
70                     'path': {'type': 'string'},
71                     'port': {'type': 'integer', 'default': 22},
72                     'host': {'type': 'string'},
73                     'user': {'type': 'string'},
74                     'ssh_key_filepath': {'type': 'string'},
75                     'allotment': {'type': 'number', 'default': -1},
76                 },
77                 'required': ['space'],
78                 'dependencies': {'host': ['user', 'ssh_key_filepath', 'path']},
79                 'additionalProperties': False,
80             },
81         ]
82     }
83 
84     @staticmethod
85     def prepare_config(config, task):
86         if isinstance(config, (float, int)):
87             config = {'space': config}
88         # Use config path if none is specified
89         if not config.get('path'):
90             config['path'] = task.manager.config_base
91         return config
92 
93     @plugin.priority(plugin.PRIORITY_FIRST)
94     def on_task_download(self, task, config):
95         config = self.prepare_config(config, task)
96         # Only bother aborting if there were accepted entries this run.
97         if not task.accepted:
98             return
99 
100         free_space = get_free_space(config, task)
101         space = config['space']
102         path = config['path']
103         if free_space < space:
104             logger.error('Less than {} MB of free space in {} aborting task.', space, path)
105             # backlog plugin will save and restore the task content, if available
106             task.abort(f"Less than {space} MB of free space in {path}")
107 
108 
109 @event('plugin.register')
110 def register_plugin():
111     plugin.register(PluginFreeSpace, 'free_space', api_ver=2)
112
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/flexget/plugins/operate/free_space.py b/flexget/plugins/operate/free_space.py
--- a/flexget/plugins/operate/free_space.py
+++ b/flexget/plugins/operate/free_space.py
@@ -7,6 +7,9 @@
 
 logger = logger.bind(name='free_space')
 
+ABORT_BELOW = 'below'
+ABORT_ABOVE = 'above'
+
 
 def get_free_space(config, task):
     """Return folder/drive free space (in megabytes)"""
@@ -67,6 +70,11 @@
                 'type': 'object',
                 'properties': {
                     'space': {'type': 'number'},
+                    'abort_if': {
+                        'type': 'string',
+                        'enum': [ABORT_BELOW, ABORT_ABOVE],
+                        'default': ABORT_BELOW,
+                    },
                     'path': {'type': 'string'},
                     'port': {'type': 'integer', 'default': 22},
                     'host': {'type': 'string'},
@@ -88,22 +96,26 @@
         # Use config path if none is specified
         if not config.get('path'):
             config['path'] = task.manager.config_base
+
         return config
 
     @plugin.priority(plugin.PRIORITY_FIRST)
     def on_task_download(self, task, config):
         config = self.prepare_config(config, task)
-        # Only bother aborting if there were accepted entries this run.
-        if not task.accepted:
-            return
 
         free_space = get_free_space(config, task)
         space = config['space']
         path = config['path']
-        if free_space < space:
+        abort_if = config['abort_if']
+
+        if free_space < space and abort_if == ABORT_BELOW:
             logger.error('Less than {} MB of free space in {} aborting task.', space, path)
             # backlog plugin will save and restore the task content, if available
             task.abort(f"Less than {space} MB of free space in {path}")
+        elif free_space > space and abort_if == ABORT_ABOVE:
+            logger.error('Over than {} MB of free space in {} aborting task.', space, path)
+            # backlog plugin will save and restore the task content, if available
+            task.abort(f"Over than {space} MB of free space in {path}")
 
 
 @event('plugin.register')

{"golden_diff": "diff --git a/flexget/plugins/operate/free_space.py b/flexget/plugins/operate/free_space.py\n--- a/flexget/plugins/operate/free_space.py\n+++ b/flexget/plugins/operate/free_space.py\n@@ -7,6 +7,9 @@\n \n logger = logger.bind(name='free_space')\n \n+ABORT_BELOW = 'below'\n+ABORT_ABOVE = 'above'\n+\n \n def get_free_space(config, task):\n     \"\"\"Return folder/drive free space (in megabytes)\"\"\"\n@@ -67,6 +70,11 @@\n                 'type': 'object',\n                 'properties': {\n                     'space': {'type': 'number'},\n+                    'abort_if': {\n+                        'type': 'string',\n+                        'enum': [ABORT_BELOW, ABORT_ABOVE],\n+                        'default': ABORT_BELOW,\n+                    },\n                     'path': {'type': 'string'},\n                     'port': {'type': 'integer', 'default': 22},\n                     'host': {'type': 'string'},\n@@ -88,22 +96,26 @@\n         # Use config path if none is specified\n         if not config.get('path'):\n             config['path'] = task.manager.config_base\n+\n         return config\n \n     @plugin.priority(plugin.PRIORITY_FIRST)\n     def on_task_download(self, task, config):\n         config = self.prepare_config(config, task)\n-        # Only bother aborting if there were accepted entries this run.\n-        if not task.accepted:\n-            return\n \n         free_space = get_free_space(config, task)\n         space = config['space']\n         path = config['path']\n-        if free_space < space:\n+        abort_if = config['abort_if']\n+\n+        if free_space < space and abort_if == ABORT_BELOW:\n             logger.error('Less than {} MB of free space in {} aborting task.', space, path)\n             # backlog plugin will save and restore the task content, if available\n             task.abort(f\"Less than {space} MB of free space in {path}\")\n+        elif free_space > space and abort_if == ABORT_ABOVE:\n+            logger.error('Over than {} MB of free space in {} aborting task.', space, path)\n+            # backlog plugin will save and restore the task content, if available\n+            task.abort(f\"Over than {space} MB of free space in {path}\")\n \n \n @event('plugin.register')\n", "issue": "Add an option to run a task for free_space, besides abort. \n<!---\nBefore opening an issue, verify:\n\n- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget\n- Is this an issue with webui? Make an issue over on https://github.com/Flexget/webui\n- Did you recently upgrade? Look at the Change Log and Upgrade Actions to make sure that you don't need to make any changes to your config https://flexget.com/ChangeLog https://flexget.com/UpgradeActions\n- Are you running FlexGet as a daemon? Stop it completely and then start it again https://flexget.com/CLI/daemon\n- Did you search to see if the issue already exists? https://github.com/Flexget/Flexget/issues\n- Did you fill out the issue template as completely as possible?\n\nThe issue template is here because it helps to ensure you submitted all the necessary information the first time, and allows us to more quickly review issues. Please fill it out correctly and do not ignore it, no matter how irrelevant you think it may be. Thanks in advance for your help with this!\n--->\n\n### Expected behaviour:\n\nRun the task when free_space on a given drive is getting low. \n\nIt is useful when we clean the old seeds, movies, etc...\n\n### Actual behaviour:\n\nFor now, it will always abort.\n\n### Steps to reproduce:\nNormal configuration.\n\n#### Config:\n```yaml\n  clean.check_free_space:\n    priority: 9\n    free_space:\n      path: /mnt/Disk1/Downloads\n      space: 30000\n    mock: [{title: \"Check.Free.Space\"}]\n    accept_all: yes\n    exec: echo \"Check free space.\"\n    disable: [seen]\n    run_task:\n      when: aborted\n      task: purge.finished_seeds\n\n  purge.finished_seeds:\n    limit_new: 2\n    <<: *from_transmission\n    if:\n      - transmission_progress != 100.0: reject\n    <<: *clean_transmission\n```\n  \n#### Log:\n<details>\n <summary>(click to expand)</summary>\n\n```\nNo need\n```\n</details>\n\n### Additional information:\n\n- FlexGet version: latest\n- Python version: \n- Installation method: docker/wiserain\n- Using daemon (yes/no):\n- OS and version:\n- Link to crash log:\n\n<!---\nIn config and debug/crash logs, remember to redact any personal or sensitive information such as passwords, API keys, private URLs and so on.\n\nPlease verify that the following data is present before submitting your issue:\n\n- Link to a paste service or paste above the relevant config (preferably full config, including templates if present). Please make sure the paste does not expire, if possible.\n- Link to a paste service or paste above debug-level logs of the relevant task/s (use `flexget -L debug execute --tasks <Task_name>`).\n- FlexGet version (use `flexget -V` to get it).\n- Full Python version, for example `2.7.11` (use `python -V` to get it). \n- Installation method (pip, git install, etc).\n- Whether or not you're running FlexGet as a daemon.\n- OS and version.\n- Attach crash log if one was generated, in addition to the debug-level log. It can be found in the directory with your config file.\n--->\n\n", "before_files": [{"content": "import os\n\nfrom loguru import logger\n\nfrom flexget import plugin\nfrom flexget.event import event\n\nlogger = logger.bind(name='free_space')\n\n\ndef get_free_space(config, task):\n    \"\"\"Return folder/drive free space (in megabytes)\"\"\"\n    if 'host' in config:\n        import paramiko\n\n        ssh = paramiko.SSHClient()\n        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())\n        try:\n            ssh.connect(\n                config['host'],\n                config['port'],\n                config['user'],\n                config['ssh_key_filepath'],\n                timeout=5000,\n            )\n        except Exception as e:\n            logger.error(\"Issue connecting to remote host. {}\", e)\n            task.abort('Error with remote host.')\n        if config['allotment'] != -1:\n            stdin, stdout, stderr = ssh.exec_command(f\"du -s {config['path']} | cut -f 1\")\n        else:\n            stdin, stdout, stderr = ssh.exec_command(\n                f\"df -k {config['path']} | tail -1 | tr -s ' ' | cut -d' ' -f4\"\n            )\n        outlines = stdout.readlines()\n        resp = ''.join(outlines)\n        ssh.close()\n        try:\n            if config['allotment'] != -1:\n                free = int(config['allotment']) - ((int(resp.strip()) * 1024) / 1000000)\n            else:\n                free = int(resp.strip()) / 1000\n        except ValueError:\n            logger.error('Non-integer was returned when calculating disk usage.')\n            task.abort('Error with remote host.')\n        return free\n    elif os.name == 'nt':\n        import ctypes\n\n        free_bytes = ctypes.c_ulonglong(0)\n        ctypes.windll.kernel32.GetDiskFreeSpaceExW(\n            ctypes.c_wchar_p(config['path']), None, None, ctypes.pointer(free_bytes)\n        )\n        return free_bytes.value / (1024 * 1024)\n    else:\n        stats = os.statvfs(config['path'])\n        return (stats.f_bavail * stats.f_frsize) / (1024 * 1024)\n\n\nclass PluginFreeSpace:\n    \"\"\"Aborts a task if an entry is accepted and there is less than a certain amount of space free on a drive.\"\"\"\n\n    schema = {\n        'oneOf': [\n            {'type': 'number'},\n            {\n                'type': 'object',\n                'properties': {\n                    'space': {'type': 'number'},\n                    'path': {'type': 'string'},\n                    'port': {'type': 'integer', 'default': 22},\n                    'host': {'type': 'string'},\n                    'user': {'type': 'string'},\n                    'ssh_key_filepath': {'type': 'string'},\n                    'allotment': {'type': 'number', 'default': -1},\n                },\n                'required': ['space'],\n                'dependencies': {'host': ['user', 'ssh_key_filepath', 'path']},\n                'additionalProperties': False,\n            },\n        ]\n    }\n\n    @staticmethod\n    def prepare_config(config, task):\n        if isinstance(config, (float, int)):\n            config = {'space': config}\n        # Use config path if none is specified\n        if not config.get('path'):\n            config['path'] = task.manager.config_base\n        return config\n\n    @plugin.priority(plugin.PRIORITY_FIRST)\n    def on_task_download(self, task, config):\n        config = self.prepare_config(config, task)\n        # Only bother aborting if there were accepted entries this run.\n        if not task.accepted:\n            return\n\n        free_space = get_free_space(config, task)\n        space = config['space']\n        path = config['path']\n        if free_space < space:\n            logger.error('Less than {} MB of free space in {} aborting task.', space, path)\n            # backlog plugin will save and restore the task content, if available\n            task.abort(f\"Less than {space} MB of free space in {path}\")\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(PluginFreeSpace, 'free_space', api_ver=2)\n", "path": "flexget/plugins/operate/free_space.py"}], "after_files": [{"content": "import os\n\nfrom loguru import logger\n\nfrom flexget import plugin\nfrom flexget.event import event\n\nlogger = logger.bind(name='free_space')\n\nABORT_BELOW = 'below'\nABORT_ABOVE = 'above'\n\n\ndef get_free_space(config, task):\n    \"\"\"Return folder/drive free space (in megabytes)\"\"\"\n    if 'host' in config:\n        import paramiko\n\n        ssh = paramiko.SSHClient()\n        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())\n        try:\n            ssh.connect(\n                config['host'],\n                config['port'],\n                config['user'],\n                config['ssh_key_filepath'],\n                timeout=5000,\n            )\n        except Exception as e:\n            logger.error(\"Issue connecting to remote host. {}\", e)\n            task.abort('Error with remote host.')\n        if config['allotment'] != -1:\n            stdin, stdout, stderr = ssh.exec_command(f\"du -s {config['path']} | cut -f 1\")\n        else:\n            stdin, stdout, stderr = ssh.exec_command(\n                f\"df -k {config['path']} | tail -1 | tr -s ' ' | cut -d' ' -f4\"\n            )\n        outlines = stdout.readlines()\n        resp = ''.join(outlines)\n        ssh.close()\n        try:\n            if config['allotment'] != -1:\n                free = int(config['allotment']) - ((int(resp.strip()) * 1024) / 1000000)\n            else:\n                free = int(resp.strip()) / 1000\n        except ValueError:\n            logger.error('Non-integer was returned when calculating disk usage.')\n            task.abort('Error with remote host.')\n        return free\n    elif os.name == 'nt':\n        import ctypes\n\n        free_bytes = ctypes.c_ulonglong(0)\n        ctypes.windll.kernel32.GetDiskFreeSpaceExW(\n            ctypes.c_wchar_p(config['path']), None, None, ctypes.pointer(free_bytes)\n        )\n        return free_bytes.value / (1024 * 1024)\n    else:\n        stats = os.statvfs(config['path'])\n        return (stats.f_bavail * stats.f_frsize) / (1024 * 1024)\n\n\nclass PluginFreeSpace:\n    \"\"\"Aborts a task if an entry is accepted and there is less than a certain amount of space free on a drive.\"\"\"\n\n    schema = {\n        'oneOf': [\n            {'type': 'number'},\n            {\n                'type': 'object',\n                'properties': {\n                    'space': {'type': 'number'},\n                    'abort_if': {\n                        'type': 'string',\n                        'enum': [ABORT_BELOW, ABORT_ABOVE],\n                        'default': ABORT_BELOW,\n                    },\n                    'path': {'type': 'string'},\n                    'port': {'type': 'integer', 'default': 22},\n                    'host': {'type': 'string'},\n                    'user': {'type': 'string'},\n                    'ssh_key_filepath': {'type': 'string'},\n                    'allotment': {'type': 'number', 'default': -1},\n                },\n                'required': ['space'],\n                'dependencies': {'host': ['user', 'ssh_key_filepath', 'path']},\n                'additionalProperties': False,\n            },\n        ]\n    }\n\n    @staticmethod\n    def prepare_config(config, task):\n        if isinstance(config, (float, int)):\n            config = {'space': config}\n        # Use config path if none is specified\n        if not config.get('path'):\n            config['path'] = task.manager.config_base\n\n        return config\n\n    @plugin.priority(plugin.PRIORITY_FIRST)\n    def on_task_download(self, task, config):\n        config = self.prepare_config(config, task)\n\n        free_space = get_free_space(config, task)\n        space = config['space']\n        path = config['path']\n        abort_if = config['abort_if']\n\n        if free_space < space and abort_if == ABORT_BELOW:\n            logger.error('Less than {} MB of free space in {} aborting task.', space, path)\n            # backlog plugin will save and restore the task content, if available\n            task.abort(f\"Less than {space} MB of free space in {path}\")\n        elif free_space > space and abort_if == ABORT_ABOVE:\n            logger.error('Over than {} MB of free space in {} aborting task.', space, path)\n            # backlog plugin will save and restore the task content, if available\n            task.abort(f\"Over than {space} MB of free space in {path}\")\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(PluginFreeSpace, 'free_space', api_ver=2)\n", "path": "flexget/plugins/operate/free_space.py"}]}