raftario / filite

A simple, light and standalone pastebin, URL shortener and file-sharing service
MIT License
190 stars 16 forks source link

Question: How to delete an entry? #18

Closed DylanVanAssche closed 4 years ago

DylanVanAssche commented 4 years ago

I really like your pastebin tool! I was trying to delete an entry using the following command:

curl -X DELETE https://username:password@bin.example.com/t/<ID>

ID is the ID of the entry (12548) when you get the output of https://username:password@bin.example.com/t:

[
  {
    "id": 12548,
    "contents": "This is a test!",
    "created": 1573691264,
    "highlight": false
  }
]

I get the reply Deleted but the entry is still there... Is this the wrong way to delete an entry?

raftario commented 4 years ago

That should work, definitely sounds like a bug. Will look into it.

raftario commented 4 years ago

Using the same command it works for me. Have you tried force refreshing the page ?

DylanVanAssche commented 4 years ago

I refreshed the page by force but it's still there. I checked the SQLite database too, the entry is still there.

Even if I submit an ID which does not exist (for example: 0 or 1), the response is still Deleted instead of Invalid ID.

raftario commented 4 years ago

Found the issue. The delete statements didn't check if anything got deleted, which I just fixed. Your issue arises from the fact you're using the numerical ID, while the deletion endpoint expects the base36 string.

I'll probably rework the tool to use the strings as IDs directly instead of numbers since that has been annoying me quite a bit, but in the meantime I'll add a simple endpoint to convert numerical IDs to base36.

raftario commented 4 years ago

The fix and the new route are on master. You can get the base36 string from a numerical ID with GET /id/{numerical_id}. You'll need to reset the password using filite passwd when updating the binary (another stupid thing I need to fix).

DylanVanAssche commented 4 years ago

Works great! Thanks!

Syndamia commented 3 years ago

I just want to mention that I made a script for more easily browsing through all of the registered string IDs, which can really help when trying to delete a lot of entries. https://github.com/Syndamia/filite-list/

raftario commented 3 years ago

@Syndamia If you want to open a PR adding a link to it in the readme on master feel free, that does look useful