Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method encryptFile() has bug #57

Open
1Patience-and-1careful opened this issue May 13, 2020 · 1 comment
Open

method encryptFile() has bug #57

1Patience-and-1careful opened this issue May 13, 2020 · 1 comment

Comments

@1Patience-and-1careful
Copy link

1Patience-and-1careful commented May 13, 2020

 private fun encryptFile() {
        val title = binding.titleEditText.text.toString()
        val body = binding.bodyEditText.text.toString()

        if (title.isBlank()) return

        try {
            deleteFile(existingFileTitle)
            val encryptedFile = getEncryptedFile(title)
            encryptedFile.openFileOutput().use { output ->
                output.write(body.toByteArray())
            }
        } catch (e: Exception) {
            e.printStackTrace()
            showSnackbar(R.string.error_unable_to_save_file)
        }
    }

should change deleteFile(existingFileTitle) to deleteFile(title )

@nic0lette
Copy link
Contributor

I'm not sure I follow why? The way I'm thinking of it is this:

Edit note: title="Test", existingFileTitle="Test"
Don't change the title, we delete existingFileTitle and create a new file title which both have the same name. (Note: You cannot overwrite an EncryptedFile)

OR
Edit note: title="Test", existingFileTitle="Test"
Change the name to "Done" -> title="Done", existingFileTitle="Test"
To save the note, we delete existingFileTitle and write title which removes the "Test" encrypted note and creates the "Done" encrypted note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants