Jump to content


How to set notification on file or folder when something is marked for delete?

Mark for Delete Alert

  • Please log in to reply
3 replies to this topic

#1 SANJAY

SANJAY

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 10 April 2019 - 02:58 PM

Hi All,

Is it possible to set notification/alert on work space or project folder to get notification whenever some files will be marked for delete by someone? How to achieve this to protect files to be deleted accidentally by someone?

Thanks in Advance,
Sanjay

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 784 posts

Posted 10 April 2019 - 07:25 PM

I'll answer the two questions separately...

Is it possible to set notification/alert on work space or project folder to get notification whenever some files will be marked for delete by someone? 


Yes, although it's a bit difficult since there isn't any such thing as an "open" trigger.  You'd need to set up a command trigger on every command that might open a file for delete:

https://www.perforce...gers.order.html

The commands to trigger on would include "p4 delete", obviously, but also "p4 reconcile", and potentially "p4 integrate", "p4 copy", and "p4 merge" if you want to also catch instances where a previous deletion is propagated from a different branch.

If you trigger on "p4 delete" it's pretty easy, but to catch the other cases you probably want to make this a post-command trigger and just run "p4 opened" immediately afterward to see if that workspace now has anything open for delete.  Not very graceful but in the case of reconcile (where behavior is dependent on client state) I don't think there's any other way to do it.  If you want to avoid duplicate notifications, you'd do that by maintaining state somewhere (probably in a lightweight database) to track when you first noticed each file was opened for delete and what revision it was opened at.

How to achieve this to protect files to be deleted accidentally by someone?


If your goal is simply to protect files from deletion, this is MUCH easier.  Set up a change-submit trigger, have it check for files open for delete, and reject the submit.  I'd estimate it as being about five lines of code in most scripting languages.

https://www.perforce...its.submit.html

#3 SANJAY

SANJAY

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 11 April 2019 - 11:08 AM

Thank you very much for detail explanation. It is really very useful.

Cheers!!!

#4 Matt Janulewicz

Matt Janulewicz

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts
  • LocationSan Francisco, CA

Posted 17 April 2019 - 12:40 AM

Personally, in our environment this is such an edge case that we don't even bother/care about it since a delete is actually just another revision and can usually be unwound if needed. It's obliterates you need to be concerned about.

If someone does a mass delete they get publicly shamed and we do whatever is best to correct it. Files legitimately need to be deleted and in a larger environment like ours I'd go insane trying to track all the potential deletes.

That being said, another tact might be to enable the command structured log and monitor it for 'user-delete' actions. We don't do this, but we do ingest those logs into Splunk and it would be rather easy to attach an alert to that.
-Matt Janulewicz
Staff SCM Engineer, Perforce Administrator
Dolby Laboratories, Inc.
1275 Market St.
San Francisco, CA 94103, USA
majanu@dolby.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users