Erpnext: Uploading different file with same name replaces the file

Created on 13 Jan 2018  路  9Comments  路  Source: frappe/erpnext

Steps to reproduce:

  • Attach a File with name "file.pdf " to an Item.
  • To another item attach a different file with the same name "file.pdf".
  • The new file.pdf replaces the old file everywhere
bug framework

Most helpful comment

Ideally if a same name exists, the system should create a new name for the file. e.g. file-1.pdf

All 9 comments

This is expected since the files are being uploaded to the same location. At the same time, each document with an attachment just contains a reference to the location of the file.

However, I think it's a good idea that each document should have its own folder.

Ideally if a same name exists, the system should create a new name for the file. e.g. file-1.pdf

@djpalshikar If file hash is different then the system creates two different records. As per me, if file hash is same then no need to keep separate versions.

screen shot 2018-01-22 at 4 37 47 pm

@saurabh6790 this is expected behaviour. But it is not what is happening. The system is replacing the files even they have different content.

@saurabh6790 I think I now see why this is happening. Strangely in case of some files the, I have found empty ContentHash, after upload.
screenshot-2018-1-23 fuel-level-transmitter pdf - ff8aea2f79

Seems an issue! Will check this.

We are facing the same issue.

We should atleast raise and exception when content hash is empty or file size is 0 and abort the file upload. @shridarpatil can you please send a patch for this.

We have been able to pin this down to socket io, this issue happens when files are uploaded through socket io, if socket io fails and falls back to http POST hashes and file sizes are always recorded, and this issue never happens.

If we stop socket IO service, this issue doesn't occur.

@realvinay I am working on this will send a PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alimalkhalifa picture alimalkhalifa  路  3Comments

rmehta picture rmehta  路  3Comments

gbard picture gbard  路  4Comments

neilLasrado picture neilLasrado  路  4Comments

vorasmit picture vorasmit  路  3Comments