From 5e89f6fe59216586ee06a3e544b195ac4038bb06 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Wed, 18 Apr 2012 19:04:10 +0200
Subject: Fix bug crashing Swift when sending non-existent file.

License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php

diff --git a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp
index c3ffc5c..e45c7f2 100644
--- a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp
+++ b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp
@@ -7,6 +7,7 @@
 #include "FileTransferOverview.h"
 
 #include <boost/bind.hpp>
+#include <boost/filesystem.hpp>
 #include <Swiften/Base/boost_bsignals.h>
 
 #include <Swiften/FileTransfer/FileTransferManager.h>
@@ -22,10 +23,12 @@ FileTransferOverview::~FileTransferOverview() {
 }
 	
 void FileTransferOverview::sendFile(const JID& jid, const std::string& filename) {
-	FileTransferController* controller = new FileTransferController(jid, filename, fileTransferManager);
-	fileTransfers.push_back(controller);
-	
-	onNewFileTransferController(controller);
+	if (boost::filesystem2::exists(filename) && boost::filesystem2::file_size(filename) > 0) {
+		FileTransferController* controller = new FileTransferController(jid, filename, fileTransferManager);
+		fileTransfers.push_back(controller);
+
+		onNewFileTransferController(controller);
+	}
 }
 
 void FileTransferOverview::handleIncomingFileTransfer(IncomingFileTransfer::ref transfer) {
-- 
cgit v0.10.2-6-g49f6