preserve filename case in Dropbox when uploading files, closes https://github.com/PhilippC/keepass2android/issues/898

This commit is contained in:
Philipp Crocoll
2021-11-15 09:32:02 +01:00
parent cd776754b5
commit 45df2d6605
3 changed files with 29 additions and 2 deletions

View File

@@ -192,7 +192,30 @@ public class DropboxV2Storage extends JavaFileStorageBase
{
ByteArrayInputStream bis = new ByteArrayInputStream(data);
try {
path = removeProtocol(path);
//try to get the file id from the path and use that to create the uploadBuilder. This should preserve the case of the path.
String id = null;
try {
id = getFileEntry(path).userData;
}
catch (Exception e)
{
//ignore. file might not exist yet.
}
if (id != null && id.length() > 0)
{
path = id;
}
else
{
path = removeProtocol(path);
}
dbxClient.files().uploadBuilder(path).withMode(WriteMode.OVERWRITE).uploadAndFinish(bis);
@@ -416,6 +439,7 @@ public class DropboxV2Storage extends JavaFileStorageBase
fileEntry.sizeInBytes = fm.getSize();
fileEntry.isDirectory = false;
fileEntry.lastModifiedTime = fm.getServerModified().getTime();
fileEntry.userData = fm.getId();
}
else if (e instanceof DeletedMetadata)
{
@@ -428,6 +452,7 @@ public class DropboxV2Storage extends JavaFileStorageBase
fileEntry.path = getProtocolId()+"://"+ e.getPathLower();
fileEntry.displayName = e.getName();
//Log.d("JFS","fileEntry="+fileEntry);
//Log.d("JFS","Ok. Dir="+fileEntry.isDirectory);
return fileEntry;

View File

@@ -48,6 +48,8 @@ public class FileEntry {
public boolean canWrite;
public long sizeInBytes;
public String displayName;
public String userData; //can be set by the storage implementation
public FileEntry()
{

View File

@@ -557,7 +557,7 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
}
});*/
storageToTest = new DropboxV2Storage(ctx,"4ybka4p4a1027n6", "3s86datjhkihwyc", !simulateRestart);
storageToTest = new DropboxV2Storage(ctx,"4ybka4p4a1027n6", "1z5lv528un9nre8", !simulateRestart);
//storageToTest = new DropboxFileStorage(ctx,"4ybka4p4a1027n6", "1z5lv528un9nre8", !simulateRestart);
//storageToTest = new DropboxAppFolderFileStorage(ctx,"ax0268uydp1ya57", "3s86datjhkihwyc", true);