@@ -988,7 +988,8 @@ private RemoteOperationResult normalUpload(OwnCloudClient client) {
988988
989989 // Initialize channel and fileLock in try-with-resources
990990 try (
991- FileChannel channel = new RandomAccessFile (mFile .getStoragePath (), "rw" ).getChannel ();
991+ RandomAccessFile randomAccessFile = new RandomAccessFile (mFile .getStoragePath (), "rw" );
992+ FileChannel channel = randomAccessFile .getChannel ();
992993 FileLock fileLock = channel .tryLock ()
993994 ) {
994995 if (fileLock == null ) {
@@ -1003,8 +1004,9 @@ private RemoteOperationResult normalUpload(OwnCloudClient client) {
10031004 if (result .isSuccess ()) {
10041005 if (temporalFile .length () == originalFile .length ()) {
10051006 // Acquire lock on temporary file
1006- try (FileChannel tempChannel = new RandomAccessFile (temporalFile .getAbsolutePath (), "rw" ).getChannel ();
1007- FileLock tempFileLock = tempChannel .tryLock ()) {
1007+ try (RandomAccessFile randomAccessTemporalFile = new RandomAccessFile (temporalFile .getAbsolutePath (), "rw" );
1008+ FileChannel tempChannel = randomAccessTemporalFile .getChannel ();
1009+ FileLock tempFileLock = tempChannel .tryLock ()) {
10081010 if (tempFileLock != null ) {
10091011 // Use the temporary channel for the upload
10101012 size = tempChannel .size ();
@@ -1551,8 +1553,10 @@ private void move(File sourceFile, File targetFile) throws IOException {
15511553 // try to copy and then delete
15521554 targetFile .createNewFile ();
15531555 try (
1554- FileChannel inChannel = new FileInputStream (sourceFile ).getChannel ();
1555- FileChannel outChannel = new FileOutputStream (targetFile ).getChannel ()
1556+ FileInputStream fis = new FileInputStream (sourceFile );
1557+ FileOutputStream fos = new FileOutputStream (targetFile );
1558+ FileChannel inChannel = fis .getChannel ();
1559+ FileChannel outChannel = fos .getChannel ()
15561560 ) {
15571561 inChannel .transferTo (0 , inChannel .size (), outChannel );
15581562 sourceFile .delete ();
0 commit comments