# Buggy code
def PrepareMergeTaskStorage(self, task_name):
    """Prepares a task storage for merging.

    Args:
      task_name (str): unique name of the task.

    Raises:
      IOError: if the storage type is not supported or
               if the temporary path for the task storage does not exist.
    """
    if self._storage_type != definitions.STORAGE_TYPE_SESSION:
        raise IOError("Unsupported storage type.")

    if not self._task_storage_path:
        raise IOError("Missing task storage path.")

    storage_file_path = os.path.join(
        self._task_storage_path, "{0:s}.plaso".format(task_name)
    )

    merge_storage_file_path = os.path.join(
        self._merge_task_storage_path, "{0:s}.plaso".format(task_name)
    )

    os.rename(storage_file_path, merge_storage_file_path)


# Traceback (OSError)
2016-08-22 16:42:31,009 [DEBUG] (Worker_00 ) PID:12271 <worker> [ProcessFileEntry] processing file entry: TSK:/ProgramData/ASUS WebStorage
2016-08-22 16:42:31,010 [DEBUG] (Worker_00 ) PID:12271 <worker> [ProcessFileEntry] done processing file entry: TSK:/ProgramData/ASUS WebStorage
2016-08-22 16:42:31,029 [WARNING] (Worker_00 ) PID:12271 <worker_process> Unhandled exception in process: Worker_00 (PID: 12271).
2016-08-22 16:42:31,029 [ERROR] (Worker_00 ) PID:12271 <worker_process> [Errno 2] No such file or directory
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/plaso/multi_processing/worker_process.py", line 200, in _Main
self._ProcessTask(task)
File "/usr/lib/python2.7/dist-packages/plaso/multi_processing/worker_process.py", line 301, in _ProcessTask
self._storage_writer.PrepareMergeTaskStorage(task.identifier)
File "/usr/lib/python2.7/dist-packages/plaso/storage/zip_file.py", line 3180, in PrepareMergeTaskStorage
os.rename(storage_file_path, merge_storage_file_path)
OSError: [Errno 2] No such file or directory
2016-08-22 16:42:31,030 [DEBUG] (Worker_00 ) PID:12271 <worker_process> Worker: Worker_00 (PID: 12271) stopped
2016-08-22 16:42:31,030 [WARNING] (Worker_00 ) PID:12271 <zeromq_queue> Worker_00 task queue queue aborting. Contents may be lost.
2016-08-22 16:42:36,124 [DEBUG] (Worker_00 ) PID:12271 <base_process> Process: Worker_00 process status RPC server stopped
2016-08-22 16:42:36,124 [DEBUG] (Worker_00 ) PID:12271 <base_process> Process: Worker_00 (PID: 12271) stopped

# Fixed code
def PrepareMergeTaskStorage(self, task_name):
    """Prepares a task storage for merging.

    Args:
      task_name (str): unique name of the task.

    Raises:
      IOError: if the storage type is not supported or
               if the temporary path for the task storage does not exist.
    """
    if self._storage_type != definitions.STORAGE_TYPE_SESSION:
        raise IOError("Unsupported storage type.")

    if not self._task_storage_path:
        raise IOError("Missing task storage path.")

    storage_file_path = os.path.join(
        self._task_storage_path, "{0:s}.plaso".format(task_name)
    )

    merge_storage_file_path = os.path.join(
        self._merge_task_storage_path, "{0:s}.plaso".format(task_name)
    )

    try:
        os.rename(storage_file_path, merge_storage_file_path)
    except OSError as exception:
        raise IOError(
            ("Unable to rename task storage file: {0:s} with error: {1:s}").format(
                storage_file_path, exception
            )
        )