We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
EmbedArt Plugin: remove_art_file doesn't seem to work
I'm running beets version 1.15. The EmbedArt plugin isn't removing the art file from the file system. 
Logfile: http://pastebin.com/n10bbdpS
Config: http://pastebin.com/ztrjd16C


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `beetsplug/embedart.py`
Content:
```
1 # This file is part of beets.
2 # Copyright 2015, Adrian Sampson.
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be
13 # included in all copies or substantial portions of the Software.
14 
15 """Allows beets to embed album art into file metadata."""
16 from __future__ import (division, absolute_import, print_function,
17                         unicode_literals)
18 
19 import os.path
20 
21 from beets.plugins import BeetsPlugin
22 from beets import ui
23 from beets.ui import decargs
24 from beets.util import syspath, normpath, displayable_path, bytestring_path
25 from beets.util.artresizer import ArtResizer
26 from beets import config
27 from beets import art
28 
29 
30 class EmbedCoverArtPlugin(BeetsPlugin):
31     """Allows albumart to be embedded into the actual files.
32     """
33     def __init__(self):
34         super(EmbedCoverArtPlugin, self).__init__()
35         self.config.add({
36             'maxwidth': 0,
37             'auto': True,
38             'compare_threshold': 0,
39             'ifempty': False,
40             'remove_art_file': False
41         })
42 
43         if self.config['maxwidth'].get(int) and not ArtResizer.shared.local:
44             self.config['maxwidth'] = 0
45             self._log.warning(u"ImageMagick or PIL not found; "
46                               u"'maxwidth' option ignored")
47         if self.config['compare_threshold'].get(int) and not \
48                 ArtResizer.shared.can_compare:
49             self.config['compare_threshold'] = 0
50             self._log.warning(u"ImageMagick 6.8.7 or higher not installed; "
51                               u"'compare_threshold' option ignored")
52 
53         self.register_listener('art_set', self.process_album)
54 
55     def commands(self):
56         # Embed command.
57         embed_cmd = ui.Subcommand(
58             'embedart', help='embed image files into file metadata'
59         )
60         embed_cmd.parser.add_option(
61             '-f', '--file', metavar='PATH', help='the image file to embed'
62         )
63         maxwidth = self.config['maxwidth'].get(int)
64         compare_threshold = self.config['compare_threshold'].get(int)
65         ifempty = self.config['ifempty'].get(bool)
66         remove_art_file = self.config['remove_art_file'].get(bool)
67 
68         def embed_func(lib, opts, args):
69             if opts.file:
70                 imagepath = normpath(opts.file)
71                 if not os.path.isfile(syspath(imagepath)):
72                     raise ui.UserError(u'image file {0} not found'.format(
73                         displayable_path(imagepath)
74                     ))
75                 for item in lib.items(decargs(args)):
76                     art.embed_item(self._log, item, imagepath, maxwidth, None,
77                                    compare_threshold, ifempty)
78             else:
79                 for album in lib.albums(decargs(args)):
80                     art.embed_album(self._log, album, maxwidth, False,
81                                     compare_threshold, ifempty)
82 
83                     if remove_art_file and album.artpath is not None:
84                         if os.path.isfile(album.artpath):
85                             self._log.debug(u'Removing album art file '
86                                             u'for {0}', album)
87                             os.remove(album.artpath)
88                             album.artpath = None
89                             album.store()
90 
91         embed_cmd.func = embed_func
92 
93         # Extract command.
94         extract_cmd = ui.Subcommand('extractart',
95                                     help='extract an image from file metadata')
96         extract_cmd.parser.add_option('-o', dest='outpath',
97                                       help='image output file')
98         extract_cmd.parser.add_option('-n', dest='filename',
99                                       help='image filename to create for all '
100                                            'matched albums')
101         extract_cmd.parser.add_option('-a', dest='associate',
102                                       action='store_true',
103                                       help='associate the extracted images '
104                                            'with the album')
105 
106         def extract_func(lib, opts, args):
107             if opts.outpath:
108                 art.extract_first(self._log, normpath(opts.outpath),
109                                   lib.items(decargs(args)))
110             else:
111                 filename = bytestring_path(opts.filename or
112                                            config['art_filename'].get())
113                 if os.path.dirname(filename) != '':
114                     self._log.error(u"Only specify a name rather than a path "
115                                     u"for -n")
116                     return
117                 for album in lib.albums(decargs(args)):
118                     artpath = normpath(os.path.join(album.path, filename))
119                     artpath = art.extract_first(self._log, artpath,
120                                                 album.items())
121                     if artpath and opts.associate:
122                         album.set_art(artpath)
123                         album.store()
124         extract_cmd.func = extract_func
125 
126         # Clear command.
127         clear_cmd = ui.Subcommand('clearart',
128                                   help='remove images from file metadata')
129 
130         def clear_func(lib, opts, args):
131             art.clear(self._log, lib, decargs(args))
132         clear_cmd.func = clear_func
133 
134         return [embed_cmd, extract_cmd, clear_cmd]
135 
136     def process_album(self, album):
137         """Automatically embed art after art has been set
138         """
139         if self.config['auto'] and config['import']['write']:
140             max_width = self.config['maxwidth'].get(int)
141             art.embed_album(self._log, album, max_width, True,
142                             self.config['compare_threshold'].get(int),
143                             self.config['ifempty'].get(bool))
144
```
--- 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/beetsplug/embedart.py b/beetsplug/embedart.py
--- a/beetsplug/embedart.py
+++ b/beetsplug/embedart.py
@@ -79,14 +79,7 @@
                 for album in lib.albums(decargs(args)):
                     art.embed_album(self._log, album, maxwidth, False,
                                     compare_threshold, ifempty)
-
-                    if remove_art_file and album.artpath is not None:
-                        if os.path.isfile(album.artpath):
-                            self._log.debug(u'Removing album art file '
-                                            u'for {0}', album)
-                            os.remove(album.artpath)
-                            album.artpath = None
-                            album.store()
+                    self.remove_artfile(album)
 
         embed_cmd.func = embed_func
 
@@ -141,3 +134,12 @@
             art.embed_album(self._log, album, max_width, True,
                             self.config['compare_threshold'].get(int),
                             self.config['ifempty'].get(bool))
+            self.remove_artfile(album)
+    def remove_artfile(self, album)
+        if self.config['remove_art_file'] and album.artpath:
+            if os.path.isfile(album.artpath):
+                self._log.debug(u'Removing album art file '
+                                u'for {0}', album)
+                os.remove(album.artpath)
+                album.artpath = None
+                album.store()

{"golden_diff": "diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py\n--- a/beetsplug/embedart.py\n+++ b/beetsplug/embedart.py\n@@ -79,14 +79,7 @@\n                 for album in lib.albums(decargs(args)):\n                     art.embed_album(self._log, album, maxwidth, False,\n                                     compare_threshold, ifempty)\n-\n-                    if remove_art_file and album.artpath is not None:\n-                        if os.path.isfile(album.artpath):\n-                            self._log.debug(u'Removing album art file '\n-                                            u'for {0}', album)\n-                            os.remove(album.artpath)\n-                            album.artpath = None\n-                            album.store()\n+                    self.remove_artfile(album)\n \n         embed_cmd.func = embed_func\n \n@@ -141,3 +134,12 @@\n             art.embed_album(self._log, album, max_width, True,\n                             self.config['compare_threshold'].get(int),\n                             self.config['ifempty'].get(bool))\n+            self.remove_artfile(album)\n+    def remove_artfile(self, album)\n+        if self.config['remove_art_file'] and album.artpath:\n+            if os.path.isfile(album.artpath):\n+                self._log.debug(u'Removing album art file '\n+                                u'for {0}', album)\n+                os.remove(album.artpath)\n+                album.artpath = None\n+                album.store()\n", "issue": "EmbedArt Plugin: remove_art_file doesn't seem to work\nI'm running beets version 1.15. The EmbedArt plugin isn't removing the art file from the file system. \nLogfile: http://pastebin.com/n10bbdpS\nConfig: http://pastebin.com/ztrjd16C\n\n", "before_files": [{"content": "# This file is part of beets.\n# Copyright 2015, Adrian Sampson.\n#\n# Permission is hereby granted, free of charge, to any person obtaining\n# a copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the Software, and to\n# permit persons to whom the Software is furnished to do so, subject to\n# the following conditions:\n#\n# The above copyright notice and this permission notice shall be\n# included in all copies or substantial portions of the Software.\n\n\"\"\"Allows beets to embed album art into file metadata.\"\"\"\nfrom __future__ import (division, absolute_import, print_function,\n                        unicode_literals)\n\nimport os.path\n\nfrom beets.plugins import BeetsPlugin\nfrom beets import ui\nfrom beets.ui import decargs\nfrom beets.util import syspath, normpath, displayable_path, bytestring_path\nfrom beets.util.artresizer import ArtResizer\nfrom beets import config\nfrom beets import art\n\n\nclass EmbedCoverArtPlugin(BeetsPlugin):\n    \"\"\"Allows albumart to be embedded into the actual files.\n    \"\"\"\n    def __init__(self):\n        super(EmbedCoverArtPlugin, self).__init__()\n        self.config.add({\n            'maxwidth': 0,\n            'auto': True,\n            'compare_threshold': 0,\n            'ifempty': False,\n            'remove_art_file': False\n        })\n\n        if self.config['maxwidth'].get(int) and not ArtResizer.shared.local:\n            self.config['maxwidth'] = 0\n            self._log.warning(u\"ImageMagick or PIL not found; \"\n                              u\"'maxwidth' option ignored\")\n        if self.config['compare_threshold'].get(int) and not \\\n                ArtResizer.shared.can_compare:\n            self.config['compare_threshold'] = 0\n            self._log.warning(u\"ImageMagick 6.8.7 or higher not installed; \"\n                              u\"'compare_threshold' option ignored\")\n\n        self.register_listener('art_set', self.process_album)\n\n    def commands(self):\n        # Embed command.\n        embed_cmd = ui.Subcommand(\n            'embedart', help='embed image files into file metadata'\n        )\n        embed_cmd.parser.add_option(\n            '-f', '--file', metavar='PATH', help='the image file to embed'\n        )\n        maxwidth = self.config['maxwidth'].get(int)\n        compare_threshold = self.config['compare_threshold'].get(int)\n        ifempty = self.config['ifempty'].get(bool)\n        remove_art_file = self.config['remove_art_file'].get(bool)\n\n        def embed_func(lib, opts, args):\n            if opts.file:\n                imagepath = normpath(opts.file)\n                if not os.path.isfile(syspath(imagepath)):\n                    raise ui.UserError(u'image file {0} not found'.format(\n                        displayable_path(imagepath)\n                    ))\n                for item in lib.items(decargs(args)):\n                    art.embed_item(self._log, item, imagepath, maxwidth, None,\n                                   compare_threshold, ifempty)\n            else:\n                for album in lib.albums(decargs(args)):\n                    art.embed_album(self._log, album, maxwidth, False,\n                                    compare_threshold, ifempty)\n\n                    if remove_art_file and album.artpath is not None:\n                        if os.path.isfile(album.artpath):\n                            self._log.debug(u'Removing album art file '\n                                            u'for {0}', album)\n                            os.remove(album.artpath)\n                            album.artpath = None\n                            album.store()\n\n        embed_cmd.func = embed_func\n\n        # Extract command.\n        extract_cmd = ui.Subcommand('extractart',\n                                    help='extract an image from file metadata')\n        extract_cmd.parser.add_option('-o', dest='outpath',\n                                      help='image output file')\n        extract_cmd.parser.add_option('-n', dest='filename',\n                                      help='image filename to create for all '\n                                           'matched albums')\n        extract_cmd.parser.add_option('-a', dest='associate',\n                                      action='store_true',\n                                      help='associate the extracted images '\n                                           'with the album')\n\n        def extract_func(lib, opts, args):\n            if opts.outpath:\n                art.extract_first(self._log, normpath(opts.outpath),\n                                  lib.items(decargs(args)))\n            else:\n                filename = bytestring_path(opts.filename or\n                                           config['art_filename'].get())\n                if os.path.dirname(filename) != '':\n                    self._log.error(u\"Only specify a name rather than a path \"\n                                    u\"for -n\")\n                    return\n                for album in lib.albums(decargs(args)):\n                    artpath = normpath(os.path.join(album.path, filename))\n                    artpath = art.extract_first(self._log, artpath,\n                                                album.items())\n                    if artpath and opts.associate:\n                        album.set_art(artpath)\n                        album.store()\n        extract_cmd.func = extract_func\n\n        # Clear command.\n        clear_cmd = ui.Subcommand('clearart',\n                                  help='remove images from file metadata')\n\n        def clear_func(lib, opts, args):\n            art.clear(self._log, lib, decargs(args))\n        clear_cmd.func = clear_func\n\n        return [embed_cmd, extract_cmd, clear_cmd]\n\n    def process_album(self, album):\n        \"\"\"Automatically embed art after art has been set\n        \"\"\"\n        if self.config['auto'] and config['import']['write']:\n            max_width = self.config['maxwidth'].get(int)\n            art.embed_album(self._log, album, max_width, True,\n                            self.config['compare_threshold'].get(int),\n                            self.config['ifempty'].get(bool))\n", "path": "beetsplug/embedart.py"}], "after_files": [{"content": "# This file is part of beets.\n# Copyright 2015, Adrian Sampson.\n#\n# Permission is hereby granted, free of charge, to any person obtaining\n# a copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the Software, and to\n# permit persons to whom the Software is furnished to do so, subject to\n# the following conditions:\n#\n# The above copyright notice and this permission notice shall be\n# included in all copies or substantial portions of the Software.\n\n\"\"\"Allows beets to embed album art into file metadata.\"\"\"\nfrom __future__ import (division, absolute_import, print_function,\n                        unicode_literals)\n\nimport os.path\n\nfrom beets.plugins import BeetsPlugin\nfrom beets import ui\nfrom beets.ui import decargs\nfrom beets.util import syspath, normpath, displayable_path, bytestring_path\nfrom beets.util.artresizer import ArtResizer\nfrom beets import config\nfrom beets import art\n\n\nclass EmbedCoverArtPlugin(BeetsPlugin):\n    \"\"\"Allows albumart to be embedded into the actual files.\n    \"\"\"\n    def __init__(self):\n        super(EmbedCoverArtPlugin, self).__init__()\n        self.config.add({\n            'maxwidth': 0,\n            'auto': True,\n            'compare_threshold': 0,\n            'ifempty': False,\n            'remove_art_file': False\n        })\n\n        if self.config['maxwidth'].get(int) and not ArtResizer.shared.local:\n            self.config['maxwidth'] = 0\n            self._log.warning(u\"ImageMagick or PIL not found; \"\n                              u\"'maxwidth' option ignored\")\n        if self.config['compare_threshold'].get(int) and not \\\n                ArtResizer.shared.can_compare:\n            self.config['compare_threshold'] = 0\n            self._log.warning(u\"ImageMagick 6.8.7 or higher not installed; \"\n                              u\"'compare_threshold' option ignored\")\n\n        self.register_listener('art_set', self.process_album)\n\n    def commands(self):\n        # Embed command.\n        embed_cmd = ui.Subcommand(\n            'embedart', help='embed image files into file metadata'\n        )\n        embed_cmd.parser.add_option(\n            '-f', '--file', metavar='PATH', help='the image file to embed'\n        )\n        maxwidth = self.config['maxwidth'].get(int)\n        compare_threshold = self.config['compare_threshold'].get(int)\n        ifempty = self.config['ifempty'].get(bool)\n        remove_art_file = self.config['remove_art_file'].get(bool)\n\n        def embed_func(lib, opts, args):\n            if opts.file:\n                imagepath = normpath(opts.file)\n                if not os.path.isfile(syspath(imagepath)):\n                    raise ui.UserError(u'image file {0} not found'.format(\n                        displayable_path(imagepath)\n                    ))\n                for item in lib.items(decargs(args)):\n                    art.embed_item(self._log, item, imagepath, maxwidth, None,\n                                   compare_threshold, ifempty)\n            else:\n                for album in lib.albums(decargs(args)):\n                    art.embed_album(self._log, album, maxwidth, False,\n                                    compare_threshold, ifempty)\n                    self.remove_artfile(album)\n\n        embed_cmd.func = embed_func\n\n        # Extract command.\n        extract_cmd = ui.Subcommand('extractart',\n                                    help='extract an image from file metadata')\n        extract_cmd.parser.add_option('-o', dest='outpath',\n                                      help='image output file')\n        extract_cmd.parser.add_option('-n', dest='filename',\n                                      help='image filename to create for all '\n                                           'matched albums')\n        extract_cmd.parser.add_option('-a', dest='associate',\n                                      action='store_true',\n                                      help='associate the extracted images '\n                                           'with the album')\n\n        def extract_func(lib, opts, args):\n            if opts.outpath:\n                art.extract_first(self._log, normpath(opts.outpath),\n                                  lib.items(decargs(args)))\n            else:\n                filename = bytestring_path(opts.filename or\n                                           config['art_filename'].get())\n                if os.path.dirname(filename) != '':\n                    self._log.error(u\"Only specify a name rather than a path \"\n                                    u\"for -n\")\n                    return\n                for album in lib.albums(decargs(args)):\n                    artpath = normpath(os.path.join(album.path, filename))\n                    artpath = art.extract_first(self._log, artpath,\n                                                album.items())\n                    if artpath and opts.associate:\n                        album.set_art(artpath)\n                        album.store()\n        extract_cmd.func = extract_func\n\n        # Clear command.\n        clear_cmd = ui.Subcommand('clearart',\n                                  help='remove images from file metadata')\n\n        def clear_func(lib, opts, args):\n            art.clear(self._log, lib, decargs(args))\n        clear_cmd.func = clear_func\n\n        return [embed_cmd, extract_cmd, clear_cmd]\n\n    def process_album(self, album):\n        \"\"\"Automatically embed art after art has been set\n        \"\"\"\n        if self.config['auto'] and config['import']['write']:\n            max_width = self.config['maxwidth'].get(int)\n            art.embed_album(self._log, album, max_width, True,\n                            self.config['compare_threshold'].get(int),\n                            self.config['ifempty'].get(bool))\n            self.remove_artfile(album)\n    def remove_artfile(self, album)\n        if self.config['remove_art_file'] and album.artpath:\n            if os.path.isfile(album.artpath):\n                self._log.debug(u'Removing album art file '\n                                u'for {0}', album)\n                os.remove(album.artpath)\n                album.artpath = None\n                album.store()\n", "path": "beetsplug/embedart.py"}]}