diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index a754f9f28c4bfd6b18046bb5daa888dc0cd31fa0..98a5f1f2f28767ec62b0074ddbd812589f9314b1 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -157,6 +157,33 @@ class Helper {
 	}
 
 
+	/**
+	 * @brief Remove .path extension from a file path
+	 * @param string $path Path that may identify a .part file
+	 * @return string File path without .part extension
+	 * @note this is needed for reusing keys
+	 */
+	public static function fixPartialFilePath($path) {
+		$extension = pathinfo($path, PATHINFO_EXTENSION);
+
+		if ( $extension === 'part' || $extension === 'etmp') {
+
+			$newLength = strlen($path) - 5; // 5 = strlen(".part") = strlen(".etmp")
+			$fPath = substr($path, 0, $newLength);
+
+			// if path also contains a transaction id, we remove it too
+			$extension = pathinfo($fPath, PATHINFO_EXTENSION);
+			if(substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
+				$newLength = strlen($fPath) - strlen($extension) -1;
+				$fPath = substr($fPath, 0, $newLength);
+			}
+			return $fPath;
+
+		} else {
+			return $path;
+		}
+	}
+
 	/**
 	 * @brief disable recovery
 	 *
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 7143fcff0f63b7719849abc40f2450ed90179494..578d8965b424b21e731be8a1d45773ec395643ae 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -155,7 +155,7 @@ class Keymanager {
 		if (self::isPartialFilePath($targetPath)) {
 
 			$result = $view->file_put_contents(
-				$basePath . '/' . self::fixPartialFilePath($targetPath) . '.key', $catfile);
+				$basePath . '/' . \OCA\Encryption\Helper::fixPartialFilePath($targetPath) . '.key', $catfile);
 
 		} else {
 
@@ -169,29 +169,6 @@ class Keymanager {
 
 	}
 
-	/**
-	 * @brief Remove .path extension from a file path
-	 * @param string $path Path that may identify a .part file
-	 * @return string File path without .part extension
-	 * @note this is needed for reusing keys
-	 */
-	public static function fixPartialFilePath($path) {
-
-		if (preg_match('/\.part$/', $path) || preg_match('/\.etmp$/', $path)) {
-
-			$newLength = strlen($path) - 5;
-			$fPath = substr($path, 0, $newLength);
-
-			return $fPath;
-
-		} else {
-
-			return $path;
-
-		}
-
-	}
-
 	/**
 	 * @brief Check if a path is a .part file
 	 * @param string $path Path that may identify a .part file
@@ -199,14 +176,11 @@ class Keymanager {
 	 */
 	public static function isPartialFilePath($path) {
 
-		if (preg_match('/\.part$/', $path) || preg_match('/\.etmp$/', $path)) {
-
+		$extension = pathinfo($path, PATHINFO_EXTENSION);
+		if ( $extension === 'part' || $extension === 'etmp') {
 			return true;
-
 		} else {
-
 			return false;
-
 		}
 
 	}
@@ -226,7 +200,7 @@ class Keymanager {
 		$util = new Util($view, \OCP\User::getUser());
 
 		list($owner, $filename) = $util->getUidAndFilename($filePath);
-		$filename = self::fixPartialFilePath($filename);
+		$filename = \OCA\Encryption\Helper::fixPartialFilePath($filename);
 		$filePath_f = ltrim($filename, '/');
 
 		// in case of system wide mount points the keys are stored directly in the data directory
@@ -386,7 +360,7 @@ class Keymanager {
 
 			// try reusing key file if part file
 			if (self::isPartialFilePath($shareKeyPath)) {
-				$writePath = $basePath . '/' . self::fixPartialFilePath($shareKeyPath) . '.' . $userId . '.shareKey';
+				$writePath = $basePath . '/' . \OCA\Encryption\Helper::fixPartialFilePath($shareKeyPath) . '.' . $userId . '.shareKey';
 			} else {
 				$writePath = $basePath . '/' . $shareKeyPath . '.' . $userId . '.shareKey';
 			}
@@ -422,7 +396,7 @@ class Keymanager {
 		$util = new Util($view, \OCP\User::getUser());
 
 		list($owner, $filename) = $util->getUidAndFilename($filePath);
-		$filename = self::fixPartialFilePath($filename);
+		$filename = \OCA\Encryption\Helper::fixPartialFilePath($filename);
 		// in case of system wide mount points the keys are stored directly in the data directory
 		if ($util->isSystemWideMountPoint($filename)) {
 			$shareKeyPath = '/files_encryption/share-keys/' . $filename . '.' . $userId . '.shareKey';
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 53d58fbf40d601c6951d052f2f643f3a5b0a9b24..9ae38a4ad8ebefd5a76dd21afbc0c40e0788cfc1 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1138,10 +1138,7 @@ class Util {
 		// Make sure that a share key is generated for the owner too
 		list($owner, $ownerPath) = $this->getUidAndFilename($filePath);
 
-		$pathinfo = pathinfo($ownerPath);
-		if(array_key_exists('extension', $pathinfo) && $pathinfo['extension'] === 'part') {
-			$ownerPath = $pathinfo['dirname'] . '/' . $pathinfo['filename'];
-		}
+		$ownerPath = \OCA\Encryption\Helper::fixPartialFilePath($ownerPath);
 
 		$userIds = array();
 		if ($sharingEnabled) {