Skip to content

method encryptFile() has bug #57

Open

Description

@1Patience-and-1careful
 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 )

Activity

  1. nic0lette commented on May 13, 2020

    @nic0lette
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions