# Buggy code
def transferFile(
    self,
    direction,
    user,
    filename,
    path="",
    transfer=None,
    size=None,
    bitrate=None,
    length=None,
    realfilename=None,
):
    """Get a single file. path is a local path. if transfer object is
    not None, update it, otherwise create a new one."""
    if transfer is None:
        transfer = Transfer(
            user=user,
            filename=filename,
            path=path,
            status="Getting status",
            size=size,
            bitrate=bitrate,
            length=length,
        )

        if direction == 0:
            self.downloads.append(transfer)
        else:
            self._updateOrAppendUpload(user, filename, transfer)
    else:
        transfer.status = "Getting status"

    try:
        status = self.users[user].status
    except KeyError:
        status = None

    if (
        not direction
        and self.eventprocessor.config.sections["transfers"]["enablefilters"]
    ):
        # Only filter downloads, never uploads!
        try:
            downloadregexp = re.compile(
                self.eventprocessor.config.sections["transfers"]["downloadregexp"], re.I
            )
            if downloadregexp.search(filename) is not None:
                self.eventprocessor.logMessage(_("Filtering: %s") % filename, 5)
                self.AbortTransfer(transfer)
                # The string to be displayed on the GUI
                transfer.status = "Filtered"
        except Exception:
            pass

    if status is None:
        if user not in self.eventprocessor.watchedusers:
            self.queue.put(slskmessages.AddUser(user))
        self.queue.put(slskmessages.GetUserStatus(user))

    if transfer.status != "Filtered":
        transfer.req = newId()
        realpath = self.eventprocessor.shares.virtual2real(filename)
        request = slskmessages.TransferRequest(
            None,
            direction,
            transfer.req,
            filename,
            self.getFileSize(realpath),
            realpath,
        )
        self.eventprocessor.ProcessRequestToPeer(user, request)

    if direction == 0:
        self.downloadspanel.update(transfer)
    else:
        self.uploadspanel.update(transfer)


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/user/projects/nicotine-plus/pynicotine/gtkgui/frame.py", line 1297, in OnNetworkEvent
self.np.events[i.__class__](i)
File "/home/user/projects/nicotine-plus/pynicotine/pynicotine.py", line 1556, in QueueUpload
self.transfers.QueueUpload(msg)
File "/home/user/projects/nicotine-plus/pynicotine/transfers.py", line 700, in QueueUpload
self._updateOrAppendUpload(user, msg.file, newupload)
File "/home/user/projects/nicotine-plus/pynicotine/transfers.py", line 614, in _updateOrAppendUpload
self.uploadspanel.replace(i, transferobj)
File "/home/user/projects/nicotine-plus/pynicotine/gtkgui/transferlist.py", line 293, in replace
for i in self.transfers:
AttributeError: 'Uploads' object has no attribute 'transfers'
Traceback (most recent call last):
File "/home/user/projects/nicotine-plus/pynicotine/gtkgui/frame.py", line 1297, in OnNetworkEvent
self.np.events[i.__class__](i)
File "/home/user/projects/nicotine-plus/pynicotine/pynicotine.py", line 1556, in QueueUpload
self.transfers.QueueUpload(msg)
File "/home/user/projects/nicotine-plus/pynicotine/transfers.py", line 700, in QueueUpload
self._updateOrAppendUpload(user, msg.file, newupload)
File "/home/user/projects/nicotine-plus/pynicotine/transfers.py", line 614, in _updateOrAppendUpload
self.uploadspanel.replace(i, transferobj)
File "/home/user/projects/nicotine-plus/pynicotine/gtkgui/transferlist.py", line 293, in replace
for i in self.transfers:
AttributeError: 'Uploads' object has no attribute 'transfers'

# Fixed code
def transferFile(
    self,
    direction,
    user,
    filename,
    path="",
    transfer=None,
    size=None,
    bitrate=None,
    length=None,
    realfilename=None,
):
    """Get a single file. path is a local path. if transfer object is
    not None, update it, otherwise create a new one."""
    if transfer is None:
        transfer = Transfer(
            user=user,
            filename=filename,
            path=path,
            status="Getting status",
            size=size,
            bitrate=bitrate,
            length=length,
        )

        if direction == 0:
            self.downloads.append(transfer)
        else:
            self._appendUpload(user, filename, transfer)
    else:
        transfer.status = "Getting status"

    try:
        status = self.users[user].status
    except KeyError:
        status = None

    if (
        not direction
        and self.eventprocessor.config.sections["transfers"]["enablefilters"]
    ):
        # Only filter downloads, never uploads!
        try:
            downloadregexp = re.compile(
                self.eventprocessor.config.sections["transfers"]["downloadregexp"], re.I
            )
            if downloadregexp.search(filename) is not None:
                self.eventprocessor.logMessage(_("Filtering: %s") % filename, 5)
                self.AbortTransfer(transfer)
                # The string to be displayed on the GUI
                transfer.status = "Filtered"
        except Exception:
            pass

    if status is None:
        if user not in self.eventprocessor.watchedusers:
            self.queue.put(slskmessages.AddUser(user))
        self.queue.put(slskmessages.GetUserStatus(user))

    if transfer.status != "Filtered":
        transfer.req = newId()
        realpath = self.eventprocessor.shares.virtual2real(filename)
        request = slskmessages.TransferRequest(
            None,
            direction,
            transfer.req,
            filename,
            self.getFileSize(realpath),
            realpath,
        )
        self.eventprocessor.ProcessRequestToPeer(user, request)

    if direction == 0:
        self.downloadspanel.update(transfer)
    else:
        self.uploadspanel.update(transfer)