<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13786] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13786">13786</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-07-24 08:56:17 -0700 (Thu, 24 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't update the TIME_RANGE table when there are no changes to it.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavstdconfigpy">CalendarServer/trunk/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingicaldiffpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy">CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py (13785 => 13786)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/stdconfig.py        2014-07-24 15:55:09 UTC (rev 13785)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py        2014-07-24 15:56:17 UTC (rev 13786)
</span><span class="lines">@@ -265,59 +265,59 @@
</span><span class="cx">     #
</span><span class="cx">     &quot;BindAddresses&quot;: [], # List of IP addresses to bind to [empty = all]
</span><span class="cx">     &quot;BindHTTPPorts&quot;: [], # List of port numbers to bind to for HTTP
</span><del>-                           # [empty = same as &quot;Port&quot;]
</del><ins>+                         # [empty = same as &quot;Port&quot;]
</ins><span class="cx">     &quot;BindSSLPorts&quot;: [], # List of port numbers to bind to for SSL
</span><del>-                           # [empty = same as &quot;SSLPort&quot;]
</del><ins>+                        # [empty = same as &quot;SSLPort&quot;]
</ins><span class="cx">     &quot;InheritFDs&quot;: [], # File descriptors to inherit for HTTP requests
</span><del>-                           # (empty = don't inherit)
</del><ins>+                      # (empty = don't inherit)
</ins><span class="cx">     &quot;InheritSSLFDs&quot;: [], # File descriptors to inherit for HTTPS requests
</span><del>-                           # (empty = don't inherit)
</del><ins>+                         # (empty = don't inherit)
</ins><span class="cx">     &quot;MetaFD&quot;: 0, # Inherited file descriptor to call recvmsg() on to
</span><del>-                           # receive sockets (none = don't inherit)
</del><ins>+                 # receive sockets (none = don't inherit)
</ins><span class="cx"> 
</span><span class="cx">     &quot;UseMetaFD&quot;: True, # Use a 'meta' FD, i.e. an FD to transmit other FDs
</span><del>-                           # to slave processes.
</del><ins>+                       # to slave processes.
</ins><span class="cx"> 
</span><span class="cx">     &quot;UseDatabase&quot;: True, # True: database; False: files
</span><span class="cx"> 
</span><span class="cx">     &quot;TransactionTimeoutSeconds&quot;: 300, # Timeout transactions that take longer than
</span><del>-                              # the specified number of seconds. Zero means
-                              # no timeouts. 5 minute default.
</del><ins>+                                      # the specified number of seconds. Zero means
+                                      # no timeouts. 5 minute default.
</ins><span class="cx"> 
</span><span class="cx">     &quot;DBType&quot;: &quot;&quot;, # 2 possible values: empty, meaning 'spawn postgres
</span><del>-                           # yourself', or 'postgres', meaning 'connect to a
-                           # postgres database as specified by the 'DSN'
-                           # configuration key.  Will support more values in
-                           # the future.
</del><ins>+                  # yourself', or 'postgres', meaning 'connect to a
+                  # postgres database as specified by the 'DSN'
+                  # configuration key.  Will support more values in
+                  # the future.
</ins><span class="cx"> 
</span><span class="cx">     &quot;SpawnedDBUser&quot;: &quot;caldav&quot;, # The username to use when DBType is empty
</span><span class="cx"> 
</span><span class="cx">     &quot;DBImportFile&quot;: &quot;&quot;, # File path to SQL file to import at startup (includes schema)
</span><span class="cx"> 
</span><span class="cx">     &quot;DSN&quot;: &quot;&quot;, # Data Source Name.  Used to connect to an external
</span><del>-                           # database if DBType is non-empty.  Format varies
-                           # depending on database type.
</del><ins>+               # database if DBType is non-empty.  Format varies
+               # depending on database type.
</ins><span class="cx"> 
</span><span class="cx">     &quot;DBAMPFD&quot;: 0, # Internally used by database to tell slave
</span><del>-                           # processes to inherit a file descriptor and use it
-                           # as an AMP connection over a UNIX socket; see
-                           # twext.enterprise.adbapi2.ConnectionPoolConnection
</del><ins>+                  # processes to inherit a file descriptor and use it
+                  # as an AMP connection over a UNIX socket; see
+                  # twext.enterprise.adbapi2.ConnectionPoolConnection
</ins><span class="cx"> 
</span><span class="cx">     &quot;SharedConnectionPool&quot;: False, # Use a shared database connection pool in
</span><del>-                                    # the master process, rather than having
-                                    # each client make its connections directly.
</del><ins>+                                   # the master process, rather than having
+                                   # each client make its connections directly.
</ins><span class="cx"> 
</span><span class="cx">     &quot;FailIfUpgradeNeeded&quot;: True, # Set to True to prevent the server or utility
</span><span class="cx">                                    # tools from running if the database needs a schema
</span><span class="cx">                                    # upgrade.
</span><span class="cx">     &quot;StopAfterUpgradeTriggerFile&quot;: &quot;stop_after_upgrade&quot;,   # if this file exists in ConfigRoot, stop
</span><del>-                                                            # the service after finishing upgrade phase
</del><ins>+                                                           # the service after finishing upgrade phase
</ins><span class="cx"> 
</span><span class="cx">     &quot;UpgradeHomePrefix&quot;: &quot;&quot;,    # When upgrading, only upgrade homes where the owner UID starts with
</span><del>-                                    # with the specified prefix. The upgrade will only be partial and only
-                                    # apply to upgrade pieces that affect entire homes. The upgrade will
-                                    # need to be run again without this prefix set to complete the overall
-                                    # upgrade.
</del><ins>+                                # with the specified prefix. The upgrade will only be partial and only
+                                # apply to upgrade pieces that affect entire homes. The upgrade will
+                                # need to be run again without this prefix set to complete the overall
+                                # upgrade.
</ins><span class="cx"> 
</span><span class="cx">     #
</span><span class="cx">     # Work queue configuration information
</span><span class="lines">@@ -652,21 +652,21 @@
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     &quot;RestrictCalendarsToOneComponentType&quot; : True, # Only allow calendars to be created with a single component type
</span><del>-                                                   # If this is on, it will also trigger an upgrade behavior that will
-                                                   # split existing calendars into multiples based on component type.
-                                                   # If on, it will also cause new accounts to provision with separate
-                                                   # calendars for events and tasks.
</del><ins>+                                                  # If this is on, it will also trigger an upgrade behavior that will
+                                                  # split existing calendars into multiples based on component type.
+                                                  # If on, it will also cause new accounts to provision with separate
+                                                  # calendars for events and tasks.
</ins><span class="cx"> 
</span><span class="cx">     &quot;SupportedComponents&quot; : [                      # Set of supported iCalendar components
</span><span class="cx">         &quot;VEVENT&quot;,
</span><span class="cx">         &quot;VTODO&quot;,
</span><del>-        #&quot;VPOLL&quot;,
</del><ins>+        # &quot;VPOLL&quot;,
</ins><span class="cx">     ],
</span><span class="cx"> 
</span><span class="cx">     &quot;ParallelUpgrades&quot; : False, # Perform upgrades - currently only the
</span><del>-                                   # database -&gt; filesystem migration - but in
-                                   # the future, hopefully all relevant
-                                   # upgrades - in parallel in subprocesses.
</del><ins>+                                # database -&gt; filesystem migration - but in
+                                # the future, hopefully all relevant
+                                # upgrades - in parallel in subprocesses.
</ins><span class="cx"> 
</span><span class="cx">     &quot;MergeUpgrades&quot;: False, # During the upgrade phase of startup, rather than
</span><span class="cx">                             # skipping homes found both on the filesystem and in
</span><span class="lines">@@ -820,13 +820,13 @@
</span><span class="cx">                 &quot;Always&quot;                          : False, # Override augments setting and always auto-schedule
</span><span class="cx">                 &quot;AllowUsers&quot;                      : False, # Allow auto-schedule for users
</span><span class="cx">                 &quot;DefaultMode&quot;                     : &quot;automatic&quot;, # Default mode for auto-schedule processing, one of:
</span><del>-                                                                   # &quot;none&quot;            - no auto-scheduling
-                                                                   # &quot;accept-always&quot;   - always accept, ignore busy time
-                                                                   # &quot;decline-always&quot;  - always decline, ignore free time
-                                                                   # &quot;accept-if-free&quot;  - accept if free, do nothing if busy
-                                                                   # &quot;decline-if-busy&quot; - decline if busy, do nothing if free
-                                                                   # &quot;automatic&quot;       - accept if free, decline if busy
-                &quot;FutureFreeBusyDays&quot;              : 3 * 365,       # How far into the future to check for booking conflicts
</del><ins>+                                                                 # &quot;none&quot;            - no auto-scheduling
+                                                                 # &quot;accept-always&quot;   - always accept, ignore busy time
+                                                                 # &quot;decline-always&quot;  - always decline, ignore free time
+                                                                 # &quot;accept-if-free&quot;  - accept if free, do nothing if busy
+                                                                 # &quot;decline-if-busy&quot; - decline if busy, do nothing if free
+                                                                 # &quot;automatic&quot;       - accept if free, decline if busy
+                &quot;FutureFreeBusyDays&quot;              : 3 * 365,     # How far into the future to check for booking conflicts
</ins><span class="cx">             },
</span><span class="cx"> 
</span><span class="cx">             &quot;WorkQueues&quot; : {
</span><span class="lines">@@ -1008,29 +1008,29 @@
</span><span class="cx">                 &quot;Port&quot;: 11311,
</span><span class="cx">                 &quot;HandleCacheTypes&quot;: [
</span><span class="cx">                     &quot;Default&quot;,
</span><del>-#                   &quot;OpenDirectoryBacker&quot;,
-#                   &quot;ImplicitUIDLock&quot;,
-#                   &quot;RefreshUIDLock&quot;,
-#                   &quot;DIGESTCREDENTIALS&quot;,
-#                   &quot;resourceInfoDB&quot;,
-#                   &quot;pubsubnodes&quot;,
-#                   &quot;FBCache&quot;,
-#                   &quot;ScheduleAddressMapper&quot;,
-#                   &quot;SQL.props&quot;,
-#                   &quot;SQL.calhome&quot;,
-#                   &quot;SQL.adbkhome&quot;,
</del><ins>+                    # &quot;OpenDirectoryBacker&quot;,
+                    # &quot;ImplicitUIDLock&quot;,
+                    # &quot;RefreshUIDLock&quot;,
+                    # &quot;DIGESTCREDENTIALS&quot;,
+                    # &quot;resourceInfoDB&quot;,
+                    # &quot;pubsubnodes&quot;,
+                    # &quot;FBCache&quot;,
+                    # &quot;ScheduleAddressMapper&quot;,
+                    # &quot;SQL.props&quot;,
+                    # &quot;SQL.calhome&quot;,
+                    # &quot;SQL.adbkhome&quot;,
</ins><span class="cx">                 ]
</span><span class="cx">             },
</span><del>-#            &quot;Shared&quot;: {
-#                &quot;ClientEnabled&quot;: True,
-#                &quot;ServerEnabled&quot;: True,
-#                &quot;BindAddress&quot;: &quot;127.0.0.1&quot;,
-#                &quot;Port&quot;: 11211,
-#                &quot;HandleCacheTypes&quot;: [
-#                    &quot;ProxyDB&quot;,
-#                    &quot;PrincipalToken&quot;,
-#                ]
-#            },
</del><ins>+            # &quot;Shared&quot;: {
+            #     &quot;ClientEnabled&quot;: True,
+            #     &quot;ServerEnabled&quot;: True,
+            #     &quot;BindAddress&quot;: &quot;127.0.0.1&quot;,
+            #     &quot;Port&quot;: 11211,
+            #     &quot;HandleCacheTypes&quot;: [
+            #         &quot;ProxyDB&quot;,
+            #         &quot;PrincipalToken&quot;,
+            #     ]
+            # },
</ins><span class="cx">         },
</span><span class="cx">         &quot;memcached&quot;: &quot;memcached&quot;, # Find in PATH
</span><span class="cx">         &quot;MaxMemory&quot;: 0, # Megabytes
</span><span class="lines">@@ -1110,6 +1110,7 @@
</span><span class="cx">     &quot;FreeBusyIndexExpandAheadDays&quot;: 365,
</span><span class="cx">     &quot;FreeBusyIndexExpandMaxDays&quot;: 5 * 365,
</span><span class="cx">     &quot;FreeBusyIndexDelayedExpand&quot;: True,
</span><ins>+    &quot;FreeBusyIndexSmartUpdate&quot;: True,
</ins><span class="cx"> 
</span><span class="cx">     # The RootResource uses a twext property store. Specify the class here
</span><span class="cx">     &quot;RootResourcePropStoreClass&quot;: &quot;txweb2.dav.xattrprops.xattrPropertyStore&quot;,
</span><span class="lines">@@ -1304,7 +1305,7 @@
</span><span class="cx">                 # non-default values later.)  -glyph
</span><span class="cx">                 if previousAbsoluteName in configDict and (
</span><span class="cx">                         configDict[previousAbsoluteName] == inDict[lastPath]
</span><del>-                    ):
</del><ins>+                ):
</ins><span class="cx">                     userSpecifiedPath = configDict[previousRelativeName]
</span><span class="cx">                 else:
</span><span class="cx">                     userSpecifiedPath = inDict[lastPath]
</span><span class="lines">@@ -1359,12 +1360,16 @@
</span><span class="cx">         maxConnections += configDict.MaxDBConnectionsPerPool
</span><span class="cx">     else:
</span><span class="cx">         # Otherwise the master *and* each worker process will be connecting
</span><del>-        maxConnections += ((configDict.MultiProcess.ProcessCount + 1) *
-            configDict.MaxDBConnectionsPerPool)
</del><ins>+        maxConnections += (
+            (configDict.MultiProcess.ProcessCount + 1) *
+            configDict.MaxDBConnectionsPerPool
+        )
</ins><span class="cx"> 
</span><span class="cx">     configDict.Postgres.MaxConnections = maxConnections
</span><del>-    configDict.Postgres.SharedBuffers = int(configDict.Postgres.MaxConnections *
-        configDict.Postgres.BuffersToConnectionsRatio)
</del><ins>+    configDict.Postgres.SharedBuffers = int(
+        configDict.Postgres.MaxConnections *
+        configDict.Postgres.BuffersToConnectionsRatio
+    )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1622,8 +1627,7 @@
</span><span class="cx">                             topic = getAPNTopicFromCertificate(certPath)
</span><span class="cx">                             service[protocol][&quot;Topic&quot;] = topic
</span><span class="cx">                         else:
</span><del>-                            log.error(&quot;APNS certificate not found: %s&quot; %
-                                (certPath,))
</del><ins>+                            log.error(&quot;APNS certificate not found: %s&quot; % (certPath,))
</ins><span class="cx">                     else:
</span><span class="cx">                         log.error(&quot;APNS certificate path not specified&quot;)
</span><span class="cx"> 
</span><span class="lines">@@ -1688,8 +1692,7 @@
</span><span class="cx">                     pass
</span><span class="cx">                 except KeychainPasswordNotFound:
</span><span class="cx">                     # The password doesn't exist in the keychain.
</span><del>-                    log.info(&quot;iMIP %s password not found in keychain&quot; %
-                        (direction,))
</del><ins>+                    log.info(&quot;iMIP %s password not found in keychain&quot; % (direction,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1755,7 +1758,7 @@
</span><span class="cx">     _preUpdateDirectoryService,
</span><span class="cx">     _preUpdateResourceService,
</span><span class="cx">     _preUpdateDirectoryAddressBookBackingDirectoryService,
</span><del>-    )
</del><ins>+)
</ins><span class="cx"> POST_UPDATE_HOOKS = (
</span><span class="cx">     _updateMultiProcess,
</span><span class="cx">     _updateDataStore,
</span><span class="lines">@@ -1773,7 +1776,7 @@
</span><span class="cx">     _updateSharing,
</span><span class="cx">     # _updateServers,
</span><span class="cx">     _updateCompliance,
</span><del>-    )
</del><ins>+)
</ins><span class="cx"> 
</span><span class="cx"> def _cleanup(configDict, defaultDict):
</span><span class="cx">     cleanDict = copy.deepcopy(configDict)
</span><span class="lines">@@ -1803,7 +1806,7 @@
</span><span class="cx">         del cleanDict[oldKey]
</span><span class="cx"> 
</span><span class="cx">     renamedOptions = {
</span><del>-#       &quot;BindAddress&quot;: &quot;BindAddresses&quot;,
</del><ins>+        # &quot;BindAddress&quot;: &quot;BindAddresses&quot;,
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for key in configDict:
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingicaldiffpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py (13785 => 13786)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py        2014-07-24 15:55:09 UTC (rev 13785)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py        2014-07-24 15:56:17 UTC (rev 13786)
</span><span class="lines">@@ -346,7 +346,7 @@
</span><span class="cx"> 
</span><span class="cx">                     # If smart_merge is happening, then derive an instance in the new data as the change in the old
</span><span class="cx">                     # data is valid and likely due to some other attendee changing their status.
</span><del>-                    if  self.smart_merge:
</del><ins>+                    if self.smart_merge:
</ins><span class="cx">                         newOverride = self.newcalendar.deriveInstance(rid, allowCancelled=True)
</span><span class="cx">                         if newOverride is None:
</span><span class="cx">                             self._logDiffError(&quot;attendeeMerge: Could not derive instance for uncancelled component: %s&quot; % (key,))
</span><span class="lines">@@ -426,7 +426,7 @@
</span><span class="cx">                 # We used to generate a 403 here - but instead we now ignore this error and let the server data
</span><span class="cx">                 # override the client
</span><span class="cx">                 self._logDiffError(&quot;attendeeMerge: Mismatched calendar objects&quot;)
</span><del>-                #return False, False, (), None
</del><ins>+                # return False, False, (), None
</ins><span class="cx">             changeCausesReply |= reply
</span><span class="cx">             if reply:
</span><span class="cx">                 changedRids.append(rid)
</span><span class="lines">@@ -646,8 +646,8 @@
</span><span class="cx">             duration = component.getProperty(&quot;DURATION&quot;)
</span><span class="cx"> 
</span><span class="cx">             timeRange = Period(
</span><del>-                start=dtstart.value()  if dtstart  is not None else None,
-                end=dtend.value()    if dtend    is not None else None,
</del><ins>+                start=dtstart.value() if dtstart is not None else None,
+                end=dtend.value() if dtend is not None else None,
</ins><span class="cx">                 duration=duration.value() if duration is not None else None,
</span><span class="cx">             )
</span><span class="cx">             newdue = None
</span><span class="lines">@@ -658,7 +658,7 @@
</span><span class="cx"> 
</span><span class="cx">             if dtstart or duration:
</span><span class="cx">                 timeRange = Period(
</span><del>-                    start=dtstart.value()  if dtstart  is not None else None,
</del><ins>+                    start=dtstart.value() if dtstart is not None else None,
</ins><span class="cx">                     duration=duration.value() if duration is not None else None,
</span><span class="cx">                 )
</span><span class="cx">             else:
</span><span class="lines">@@ -737,7 +737,7 @@
</span><span class="cx">         return partstatChanged
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def whatIsDifferent(self):
</del><ins>+    def whatIsDifferent(self, isiTip=True):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Compare the two calendar objects in their entirety and return a list of properties
</span><span class="cx">         and PARTSTAT parameters that are different.
</span><span class="lines">@@ -766,7 +766,7 @@
</span><span class="cx">         for key in (oldset &amp; newset):
</span><span class="cx">             component1 = oldmap[key]
</span><span class="cx">             component2 = newmap[key]
</span><del>-            self._diffComponents(component1, component2, rids)
</del><ins>+            self._diffComponents(component1, component2, rids, isiTip)
</ins><span class="cx"> 
</span><span class="cx">         # Now verify that each additional component in oldset matches a derived component in newset
</span><span class="cx">         for key in oldset - newset:
</span><span class="lines">@@ -774,7 +774,7 @@
</span><span class="cx">             newcomponent = self.newcalendar.deriveInstance(key[2])
</span><span class="cx">             if newcomponent is None:
</span><span class="cx">                 continue
</span><del>-            self._diffComponents(oldcomponent, newcomponent, rids)
</del><ins>+            self._diffComponents(oldcomponent, newcomponent, rids, isiTip)
</ins><span class="cx"> 
</span><span class="cx">         # Now verify that each additional component in oldset matches a derived component in newset
</span><span class="cx">         for key in newset - oldset:
</span><span class="lines">@@ -782,11 +782,45 @@
</span><span class="cx">             if oldcomponent is None:
</span><span class="cx">                 continue
</span><span class="cx">             newcomponent = newmap[key]
</span><del>-            self._diffComponents(oldcomponent, newcomponent, rids)
</del><ins>+            self._diffComponents(oldcomponent, newcomponent, rids, isiTip)
</ins><span class="cx"> 
</span><span class="cx">         return rids
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    TRPROPS = frozenset((
+        &quot;DTSTART&quot;,
+        &quot;DTEND&quot;,
+        &quot;DURATION&quot;,
+        &quot;DUE&quot;,
+        &quot;RECURRENCE-ID&quot;,
+        &quot;RRULE&quot;,
+        &quot;RDATE&quot;,
+        &quot;EXDATE&quot;,
+        &quot;STATUS&quot;,
+        &quot;TRANSP&quot;,
+        &quot;X-APPLE-TRAVEL-START&quot;,
+        &quot;X-APPLE-TRAVEL-DURATION&quot;,
+        &quot;X-APPLE-TRAVEL-RETURN&quot;,
+        &quot;X-APPLE-TRAVEL-RETURN-DURATION&quot;,
+    ))
+
+    def timeRangeDifference(self):
+        &quot;&quot;&quot;
+        Is there a difference between the two components that implies a change to the time or
+        transparency/status of any instance.
+
+        @return: L{True} if there is such a change, L{False} otherwise
+        @rtype: L{bool}
+        &quot;&quot;&quot;
+
+        for props in self.whatIsDifferent(isiTip=False).values():
+            props = frozenset(props.keys())
+            if props &amp; self.TRPROPS:
+                return True
+        else:
+            return False
+
+
</ins><span class="cx">     def attendeeNeedsAction(self, diffs):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Given a set of results from L{whatIsDifferent}, determine which recurrence-id's
</span><span class="lines">@@ -856,20 +890,21 @@
</span><span class="cx">         return (date_changed_rids, recurrence_reschedule,)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def _componentDuplicateAndNormalize(self, comp):
</del><ins>+    def _componentDuplicateAndNormalize(self, comp, isiTip=True):
</ins><span class="cx">         comp = comp.duplicate()
</span><span class="cx">         comp.normalizePropertyValueLists(&quot;EXDATE&quot;)
</span><del>-        comp.removePropertyParameters(&quot;ORGANIZER&quot;, (&quot;SCHEDULE-STATUS&quot;,))
-        comp.removePropertyParameters(&quot;ATTENDEE&quot;, (&quot;SCHEDULE-STATUS&quot;, &quot;SCHEDULE-FORCE-SEND&quot;,))
-        comp.removePropertyParameters(&quot;VOTER&quot;, (&quot;SCHEDULE-STATUS&quot;, &quot;SCHEDULE-FORCE-SEND&quot;,))
</del><span class="cx">         comp.removeAlarms()
</span><span class="cx">         comp.normalizeAll()
</span><span class="cx">         comp.normalizeAttachments()
</span><del>-        iTipGenerator.prepareSchedulingMessage(comp, reply=True)
</del><ins>+        if isiTip:
+            comp.removePropertyParameters(&quot;ORGANIZER&quot;, (&quot;SCHEDULE-STATUS&quot;,))
+            comp.removePropertyParameters(&quot;ATTENDEE&quot;, (&quot;SCHEDULE-STATUS&quot;, &quot;SCHEDULE-FORCE-SEND&quot;,))
+            comp.removePropertyParameters(&quot;VOTER&quot;, (&quot;SCHEDULE-STATUS&quot;, &quot;SCHEDULE-FORCE-SEND&quot;,))
+            iTipGenerator.prepareSchedulingMessage(comp, reply=True)
</ins><span class="cx">         return comp
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def _diffComponents(self, comp1, comp2, rids):
</del><ins>+    def _diffComponents(self, comp1, comp2, rids, isiTip=True):
</ins><span class="cx"> 
</span><span class="cx">         assert isinstance(comp1, Component) and isinstance(comp2, Component)
</span><span class="cx"> 
</span><span class="lines">@@ -878,8 +913,8 @@
</span><span class="cx">             return
</span><span class="cx"> 
</span><span class="cx">         # Duplicate then normalize for comparison
</span><del>-        comp1 = self._componentDuplicateAndNormalize(comp1)
-        comp2 = self._componentDuplicateAndNormalize(comp2)
</del><ins>+        comp1 = self._componentDuplicateAndNormalize(comp1, isiTip)
+        comp2 = self._componentDuplicateAndNormalize(comp2, isiTip)
</ins><span class="cx"> 
</span><span class="cx">         # Diff all the properties
</span><span class="cx">         propdiff = set(comp1.properties()) ^ set(comp2.properties())
</span><span class="lines">@@ -888,7 +923,6 @@
</span><span class="cx">         propsChanged = {}
</span><span class="cx">         for prop in propdiff:
</span><span class="cx">             if prop.name() in (
</span><del>-                &quot;TRANSP&quot;,
</del><span class="cx">                 &quot;DTSTAMP&quot;,
</span><span class="cx">                 &quot;CREATED&quot;,
</span><span class="cx">                 &quot;LAST-MODIFIED&quot;,
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py (13785 => 13786)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2014-07-24 15:55:09 UTC (rev 13785)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2014-07-24 15:56:17 UTC (rev 13786)
</span><span class="lines">@@ -164,7 +164,7 @@
</span><span class="cx">         self.recipient_calendar_resource = None
</span><span class="cx">         calendar_resource = (yield getCalendarObjectForRecord(self.txn, self.recipient.record, self.uid))
</span><span class="cx">         if calendar_resource:
</span><del>-            self.recipient_calendar = (yield calendar_resource.componentForUser(self.recipient.record.uid))
</del><ins>+            self.recipient_calendar = (yield calendar_resource.componentForUser(self.recipient.record.uid)).duplicate()
</ins><span class="cx">             self.recipient_calendar_resource = calendar_resource
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (13785 => 13786)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-07-24 15:55:09 UTC (rev 13785)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-07-24 15:56:17 UTC (rev 13786)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> from txdav.caldav.datastore.query.filter import Filter
</span><span class="cx"> from txdav.caldav.datastore.query.generator import CalDAVSQLQueryGenerator
</span><span class="cx"> from txdav.caldav.datastore.scheduling.cuaddress import calendarUserFromCalendarUserAddress
</span><ins>+from txdav.caldav.datastore.scheduling.icaldiff import iCalDiff
</ins><span class="cx"> from txdav.caldav.datastore.scheduling.icalsplitter import iCalSplitter
</span><span class="cx"> from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
</span><span class="cx"> from txdav.caldav.datastore.scheduling.utils import uidFromCalendarUserAddress
</span><span class="lines">@@ -1490,9 +1491,10 @@
</span><span class="cx">         return Select(
</span><span class="cx">             [co.RESOURCE_NAME],
</span><span class="cx">             From=co,
</span><del>-            Where=((co.RECURRANCE_MIN &gt; Parameter(&quot;minDate&quot;))
-                .Or(co.RECURRANCE_MAX &lt; Parameter(&quot;maxDate&quot;)))
-                .And(co.CALENDAR_RESOURCE_ID == Parameter(&quot;resourceID&quot;))
</del><ins>+            Where=(
+                (co.RECURRANCE_MIN &gt; Parameter(&quot;minDate&quot;))
+                .Or(co.RECURRANCE_MAX &lt; Parameter(&quot;maxDate&quot;))
+            ).And(co.CALENDAR_RESOURCE_ID == Parameter(&quot;resourceID&quot;))
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1750,10 +1752,11 @@
</span><span class="cx">             resourceID=child._resourceID
</span><span class="cx">         )
</span><span class="cx"> 
</span><ins>+    # ===============================================================================
+    # Group sharing
+    # ===============================================================================
</ins><span class="cx"> 
</span><del>-    #===============================================================================
-    # Group sharing
-    #===============================================================================
</del><ins>+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def reconcileGroupSharee(self, groupUID):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -1775,9 +1778,9 @@
</span><span class="cx">                         [bind.HOME_RESOURCE_ID],
</span><span class="cx">                         From=bind,
</span><span class="cx">                         Where=(bind.CALENDAR_RESOURCE_ID == self._resourceID).And(
</span><del>-                            (bind.BIND_MODE == _BIND_MODE_GROUP).Or(
-                             bind.BIND_MODE == _BIND_MODE_GROUP_READ).Or(
-                             bind.BIND_MODE == _BIND_MODE_GROUP_WRITE)
</del><ins>+                            (bind.BIND_MODE == _BIND_MODE_GROUP)
+                            .Or(bind.BIND_MODE == _BIND_MODE_GROUP_READ)
+                            .Or(bind.BIND_MODE == _BIND_MODE_GROUP_WRITE)
</ins><span class="cx">                         )
</span><span class="cx">                     )
</span><span class="cx">                 )
</span><span class="lines">@@ -1825,7 +1828,7 @@
</span><span class="cx">             rows = yield Select(
</span><span class="cx">                 [Count(gs.GROUP_ID)],
</span><span class="cx">                 From=gs,
</span><del>-                 Where=(
</del><ins>+                Where=(
</ins><span class="cx">                     gs.GROUP_ID.In(
</span><span class="cx">                         Select(
</span><span class="cx">                             [gm.GROUP_ID],
</span><span class="lines">@@ -1871,7 +1874,7 @@
</span><span class="cx">         rows = yield Select(
</span><span class="cx">             [Count(gs.GROUP_ID)],
</span><span class="cx">             From=gs,
</span><del>-             Where=(
</del><ins>+            Where=(
</ins><span class="cx">                 gs.GROUP_ID.In(
</span><span class="cx">                     Select(
</span><span class="cx">                         [gm.GROUP_ID],
</span><span class="lines">@@ -1957,7 +1960,7 @@
</span><span class="cx">             rows = yield Select(
</span><span class="cx">                 [Max(gs.GROUP_BIND_MODE)], # _BIND_MODE_WRITE &gt; _BIND_MODE_READ
</span><span class="cx">                 From=gs,
</span><del>-                 Where=(
</del><ins>+                Where=(
</ins><span class="cx">                     gs.GROUP_ID.In(
</span><span class="cx">                         Select(
</span><span class="cx">                             [gm.GROUP_ID],
</span><span class="lines">@@ -2224,7 +2227,7 @@
</span><span class="cx">             &quot;_created&quot;,
</span><span class="cx">             &quot;_modified&quot;,
</span><span class="cx">             &quot;_dataversion&quot;,
</span><del>-         )
</del><ins>+        )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @property
</span><span class="lines">@@ -2358,22 +2361,19 @@
</span><span class="cx"> 
</span><span class="cx">             if groupID in groupIDToMembershipHashMap:
</span><span class="cx">                 if groupIDToMembershipHashMap[groupID] != membershipHash:
</span><del>-                    yield Update({
-                            ga.MEMBERSHIP_HASH: membershipHash,
-                        },
</del><ins>+                    yield Update(
+                        {ga.MEMBERSHIP_HASH: membershipHash, },
</ins><span class="cx">                         Where=(ga.RESOURCE_ID == self._resourceID).And(
</span><del>-                            ga.GROUP_ID == groupID
-                        )
</del><ins>+                            ga.GROUP_ID == groupID)
</ins><span class="cx">                     ).on(self._txn)
</span><span class="cx">                     changed = True
</span><span class="cx">                 del groupIDToMembershipHashMap[groupID]
</span><span class="cx">             else:
</span><span class="cx">                 yield Insert({
</span><del>-                        ga.RESOURCE_ID: self._resourceID,
-                        ga.GROUP_ID: groupID,
-                        ga.MEMBERSHIP_HASH: membershipHash,
-                    }
-                ).on(self._txn)
</del><ins>+                    ga.RESOURCE_ID: self._resourceID,
+                    ga.GROUP_ID: groupID,
+                    ga.MEMBERSHIP_HASH: membershipHash,
+                }).on(self._txn)
</ins><span class="cx">                 changed = True
</span><span class="cx"> 
</span><span class="cx">         if groupIDToMembershipHashMap:
</span><span class="lines">@@ -2506,7 +2506,7 @@
</span><span class="cx">                         &quot;Attendee list size {0} is larger than allowed limit {1}&quot;.format(
</span><span class="cx">                             attendeeListLength, config.MaxAttendeesPerInstance
</span><span class="cx">                         )
</span><del>-                )
</del><ins>+                    )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -2523,13 +2523,15 @@
</span><span class="cx">             # Check for an allowed change
</span><span class="cx">             if organizer is None and (
</span><span class="cx">                 cutype == &quot;ROOM&quot; and not config.Scheduling.Options.AllowLocationWithoutOrganizer or
</span><del>-                cutype == &quot;RESOURCE&quot; and not config.Scheduling.Options.AllowResourceWithoutOrganizer):
</del><ins>+                cutype == &quot;RESOURCE&quot; and not config.Scheduling.Options.AllowResourceWithoutOrganizer
+            ):
</ins><span class="cx">                 raise ValidOrganizerError(&quot;Organizer required in calendar data for a {0}&quot;.format(cutype.lower(),))
</span><span class="cx"> 
</span><span class="cx">             # Check for tracking the modifier
</span><span class="cx">             if organizer is None and (
</span><span class="cx">                 cutype == &quot;ROOM&quot; and config.Scheduling.Options.TrackUnscheduledLocationData or
</span><del>-                cutype == &quot;RESOURCE&quot; and config.Scheduling.Options.TrackUnscheduledResourceData):
</del><ins>+                cutype == &quot;RESOURCE&quot; and config.Scheduling.Options.TrackUnscheduledResourceData
+            ):
</ins><span class="cx"> 
</span><span class="cx">                 # Find current principal and update modified by details
</span><span class="cx">                 authz = yield self.directoryService().recordWithUID(self.calendar().viewerHome().authzuid().decode(&quot;utf-8&quot;))
</span><span class="lines">@@ -2588,7 +2590,7 @@
</span><span class="cx">                 &quot;X-CALENDARSERVER-ATTENDEE-COMMENT&quot;,
</span><span class="cx">             ))
</span><span class="cx"> 
</span><del>-            if old_has_private_comments and not new_has_private_comments:
</del><ins>+            if old_has_private_comments and not new_has_private_comments and internal_state == ComponentUpdateState.NORMAL:
</ins><span class="cx">                 # Transfer old comments to new calendar
</span><span class="cx">                 log.debug(&quot;Organizer private comment properties were entirely removed by the client. Restoring existing properties.&quot;)
</span><span class="cx">                 old_calendar = (yield self.componentForUser())
</span><span class="lines">@@ -2813,12 +2815,16 @@
</span><span class="cx">                                         &quot;X-APPLE-RADIUS&quot;: &quot;71&quot;,
</span><span class="cx">                                         &quot;X-TITLE&quot;: title,
</span><span class="cx">                                     }
</span><del>-                                    structured = Property(&quot;X-APPLE-STRUCTURED-LOCATION&quot;,
</del><ins>+                                    structured = Property(
+                                        &quot;X-APPLE-STRUCTURED-LOCATION&quot;,
</ins><span class="cx">                                         geo.encode(&quot;utf-8&quot;), params=params,
</span><del>-                                        valuetype=Value.VALUETYPE_URI)
</del><ins>+                                        valuetype=Value.VALUETYPE_URI
+                                    )
</ins><span class="cx">                                     sub.replaceProperty(structured)
</span><del>-                                    newLocProperty = Property(&quot;LOCATION&quot;,
-                                        &quot;{0}\n{1}&quot;.format(title, street.encode(&quot;utf-8&quot;)))
</del><ins>+                                    newLocProperty = Property(
+                                        &quot;LOCATION&quot;,
+                                        &quot;{0}\n{1}&quot;.format(title, street.encode(&quot;utf-8&quot;))
+                                    )
</ins><span class="cx">                                     sub.replaceProperty(newLocProperty)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -3125,6 +3131,14 @@
</span><span class="cx">                 if did_implicit_action:
</span><span class="cx">                     self._componentChanged = True
</span><span class="cx"> 
</span><ins>+            if not hasattr(self, &quot;tr_change&quot;):
+                if inserting or hasattr(component, &quot;noInstanceIndexing&quot;) or not config.FreeBusyIndexSmartUpdate:
+                    self.tr_change = None
+                else:
+                    oldcomponent = yield self.componentForUser()
+                    self.tr_change = iCalDiff(oldcomponent, component, False).timeRangeDifference()
+
+
</ins><span class="cx">             # Always do the per-user data merge right before we store
</span><span class="cx">             component = (yield self.mergePerUserData(component, inserting))
</span><span class="cx"> 
</span><span class="lines">@@ -3162,8 +3176,10 @@
</span><span class="cx">             category = ChangeCategory.inbox
</span><span class="cx">         elif internal_state == ComponentUpdateState.ORGANIZER_ITIP_UPDATE:
</span><span class="cx">             category = ChangeCategory.organizerITIPUpdate
</span><del>-        elif (internal_state == ComponentUpdateState.ATTENDEE_ITIP_UPDATE and
-            hasattr(self._txn, &quot;doing_attendee_refresh&quot;)):
</del><ins>+        elif (
+            internal_state == ComponentUpdateState.ATTENDEE_ITIP_UPDATE and
+            hasattr(self._txn, &quot;doing_attendee_refresh&quot;)
+        ):
</ins><span class="cx">             category = ChangeCategory.attendeeITIPUpdate
</span><span class="cx"> 
</span><span class="cx">         yield self._calendar.notifyChanged(category=category)
</span><span class="lines">@@ -3201,7 +3217,12 @@
</span><span class="cx">         # In some cases there is no need to remove/rebuild the instance index because we know no time or
</span><span class="cx">         # freebusy related properties have changed (e.g. an attendee reply and refresh). In those cases
</span><span class="cx">         # the component will have a special attribute present to let us know to suppress the instance indexing.
</span><del>-        instanceIndexingRequired = not getattr(component, &quot;noInstanceIndexing&quot;, False) or inserting or reCreate
</del><ins>+        if inserting or reCreate:
+            instanceIndexingRequired = True
+        elif getattr(component, &quot;noInstanceIndexing&quot;, False):
+            instanceIndexingRequired = False
+        else:
+            instanceIndexingRequired = getattr(self, &quot;tr_change&quot;, True) in (None, True)
</ins><span class="cx">         instances = None
</span><span class="cx"> 
</span><span class="cx">         if instanceIndexingRequired:
</span><span class="lines">@@ -3276,7 +3297,7 @@
</span><span class="cx"> 
</span><span class="cx">             # Now coerce indexing to off if needed
</span><span class="cx">             if not doInstanceIndexing:
</span><del>-                #instances = None # used by removeOldEventGroupLink() call at end
</del><ins>+                # instances = None # used by removeOldEventGroupLink() call at end
</ins><span class="cx">                 recurrenceLowerLimit = None
</span><span class="cx">                 recurrenceLimit = DateTime(1900, 1, 1, 0, 0, 0, tzid=Timezone(utc=True))
</span><span class="cx"> 
</span><span class="lines">@@ -3514,8 +3535,8 @@
</span><span class="cx">                 self.log.error(
</span><span class="cx">                     &quot;Calendar data id={0} had unfixable problems:\n  {1}&quot;.format(
</span><span class="cx">                         self._resourceID, &quot;\n  &quot;.join(unfixed),
</span><del>-                        )
</del><span class="cx">                     )
</span><ins>+                )
</ins><span class="cx"> 
</span><span class="cx">             if fixed:
</span><span class="cx">                 self.log.error(
</span><span class="lines">@@ -3695,8 +3716,7 @@
</span><span class="cx">         txn = txn if txn is not None else self._txn
</span><span class="cx"> 
</span><span class="cx">         rMin, rMax = (
</span><del>-            yield self._recurrenceMinMaxByIDQuery.on(txn,
-                                         resourceID=self._resourceID)
</del><ins>+            yield self._recurrenceMinMaxByIDQuery.on(txn, resourceID=self._resourceID)
</ins><span class="cx">         )[0]
</span><span class="cx">         returnValue((
</span><span class="cx">             parseSQLDateToPyCalendar(rMin) if rMin is not None else None,
</span><span class="lines">@@ -4535,7 +4555,7 @@
</span><span class="cx">                 returnValue(None)
</span><span class="cx"> 
</span><span class="cx">             # Check it is still split-able
</span><del>-            will = (yield  cobj.willSplit())
</del><ins>+            will = (yield cobj.willSplit())
</ins><span class="cx"> 
</span><span class="cx">             if will:
</span><span class="cx">                 # Now do the spitting
</span><span class="lines">@@ -4606,8 +4626,7 @@
</span><span class="cx">         # prevented from committing successfully.  It's not valid to have an
</span><span class="cx">         # attachment that doesn't point to a real file.
</span><span class="cx"> 
</span><del>-        home = (yield self._txn.calendarHomeWithResourceID(
-                    self._attachment._ownerHomeID))
</del><ins>+        home = (yield self._txn.calendarHomeWithResourceID(self._attachment._ownerHomeID))
</ins><span class="cx"> 
</span><span class="cx">         oldSize = self._attachment.size()
</span><span class="cx">         newSize = self._file.tell()
</span><span class="lines">@@ -4691,7 +4710,7 @@
</span><span class="cx">         att = schema.ATTACHMENT
</span><span class="cx">         if self._dropboxID:
</span><span class="cx">             where = (att.DROPBOX_ID == self._dropboxID).And(
</span><del>-                   att.PATH == self._name)
</del><ins>+                att.PATH == self._name)
</ins><span class="cx">         else:
</span><span class="cx">             where = (att.ATTACHMENT_ID == self._attachmentID)
</span><span class="cx">         rows = (yield Select(
</span><span class="lines">@@ -5399,7 +5418,7 @@
</span><span class="cx">         yield Delete(
</span><span class="cx">             From=attco,
</span><span class="cx">             Where=(attco.ATTACHMENT_ID == self._attachmentID).And(
</span><del>-                   attco.CALENDAR_OBJECT_RESOURCE_ID == resourceID),
</del><ins>+                attco.CALENDAR_OBJECT_RESOURCE_ID == resourceID),
</ins><span class="cx">         ).on(self._txn)
</span><span class="cx"> 
</span><span class="cx">         # References still exist - if not remove actual attachment
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py (13785 => 13786)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2014-07-24 15:55:09 UTC (rev 13785)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2014-07-24 15:56:17 UTC (rev 13786)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx"> from txdav.caldav.datastore.scheduling.itip import iTIPRequestStatus
</span><span class="cx"> from txdav.caldav.datastore.scheduling.processing import ImplicitProcessor
</span><span class="cx"> from txdav.caldav.datastore.scheduling.scheduler import ScheduleResponseQueue
</span><del>-from txdav.caldav.datastore.sql import CalendarStoreFeatures
</del><ins>+from txdav.caldav.datastore.sql import CalendarStoreFeatures, CalendarObject
</ins><span class="cx"> from txdav.common.datastore.sql import ECALENDARTYPE, CommonObjectResource, \
</span><span class="cx">     CommonStoreTransactionMonitor
</span><span class="cx"> from txdav.common.datastore.sql_tables import schema, _BIND_MODE_DIRECT, \
</span><span class="lines">@@ -192,8 +192,7 @@
</span><span class="cx">         toHome = yield self.transactionUnderTest().calendarHomeWithUID(
</span><span class="cx">             &quot;new-home&quot;, create=True)
</span><span class="cx">         toCalendar = yield toHome.calendarWithName(&quot;calendar&quot;)
</span><del>-        ok, bad = (yield _migrateCalendar(fromCalendar, toCalendar,
-                               lambda x: x.component()))
</del><ins>+        ok, bad = (yield _migrateCalendar(fromCalendar, toCalendar, lambda x: x.component()))
</ins><span class="cx">         self.assertEqual(ok, 1)
</span><span class="cx">         self.assertEqual(bad, 2)
</span><span class="cx"> 
</span><span class="lines">@@ -212,8 +211,7 @@
</span><span class="cx">         toHome = yield self.transactionUnderTest().calendarHomeWithUID(
</span><span class="cx">             &quot;new-home&quot;, create=True)
</span><span class="cx">         toCalendar = yield toHome.calendarWithName(&quot;calendar&quot;)
</span><del>-        ok, bad = (yield _migrateCalendar(fromCalendar, toCalendar,
-                               lambda x: x.component()))
</del><ins>+        ok, bad = (yield _migrateCalendar(fromCalendar, toCalendar, lambda x: x.component()))
</ins><span class="cx">         self.assertEqual(ok, 3)
</span><span class="cx">         self.assertEqual(bad, 0)
</span><span class="cx"> 
</span><span class="lines">@@ -400,8 +398,7 @@
</span><span class="cx">         toHome = yield self.transactionUnderTest().calendarHomeWithUID(
</span><span class="cx">             &quot;home_attachments&quot;, create=True)
</span><span class="cx">         toCalendar = yield toHome.calendarWithName(&quot;calendar&quot;)
</span><del>-        ok, bad = (yield _migrateCalendar(fromCalendar, toCalendar,
-                               lambda x: x.component()))
</del><ins>+        ok, bad = (yield _migrateCalendar(fromCalendar, toCalendar, lambda x: x.component()))
</ins><span class="cx">         self.assertEqual(ok, 3)
</span><span class="cx">         self.assertEqual(bad, 0)
</span><span class="cx"> 
</span><span class="lines">@@ -421,14 +418,14 @@
</span><span class="cx">                                lambda x: x.component())
</span><span class="cx"> 
</span><span class="cx">         filter = caldavxml.Filter(
</span><del>-                      caldavxml.ComponentFilter(
-                          caldavxml.ComponentFilter(
-                              caldavxml.TimeRange(start=&quot;%(now)s0201T000000Z&quot; % self.nowYear, end=&quot;%(now)s0202T000000Z&quot; % self.nowYear),
-                              name=(&quot;VEVENT&quot;, &quot;VFREEBUSY&quot;, &quot;VAVAILABILITY&quot;),
-                          ),
-                          name=&quot;VCALENDAR&quot;,
-                       )
-                  )
</del><ins>+            caldavxml.ComponentFilter(
+                caldavxml.ComponentFilter(
+                    caldavxml.TimeRange(start=&quot;%(now)s0201T000000Z&quot; % self.nowYear, end=&quot;%(now)s0202T000000Z&quot; % self.nowYear),
+                    name=(&quot;VEVENT&quot;, &quot;VFREEBUSY&quot;, &quot;VAVAILABILITY&quot;),
+                ),
+                name=&quot;VCALENDAR&quot;,
+            )
+        )
</ins><span class="cx">         filter = Filter(filter)
</span><span class="cx">         filter.settimezone(None)
</span><span class="cx"> 
</span><span class="lines">@@ -640,8 +637,7 @@
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def _defer1():
</span><del>-            yield cal1.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(
-&quot;&quot;&quot;BEGIN:VCALENDAR
</del><ins>+            yield cal1.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(&quot;&quot;&quot;BEGIN:VCALENDAR
</ins><span class="cx"> VERSION:2.0
</span><span class="cx"> PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -686,8 +682,7 @@
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def _defer2():
</span><del>-            yield cal2.createObjectResourceWithName(&quot;2.ics&quot;, Component.fromString(
-&quot;&quot;&quot;BEGIN:VCALENDAR
</del><ins>+            yield cal2.createObjectResourceWithName(&quot;2.ics&quot;, Component.fromString(&quot;&quot;&quot;BEGIN:VCALENDAR
</ins><span class="cx"> VERSION:2.0
</span><span class="cx"> PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -768,7 +763,7 @@
</span><span class="cx">         txn2 = calendarStore.newTransaction()
</span><span class="cx"> 
</span><span class="cx">         notification_uid1_1 = yield txn1.notificationsWithUID(
</span><del>-           &quot;uid1&quot;,
</del><ins>+            &quot;uid1&quot;,
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="lines">@@ -813,9 +808,11 @@
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         prop = schema.RESOURCE_PROPERTY
</span><del>-        _allWithID = Select([prop.NAME, prop.VIEWER_UID, prop.VALUE],
-                        From=prop,
-                        Where=prop.RESOURCE_ID == Parameter(&quot;resourceID&quot;))
</del><ins>+        _allWithID = Select(
+            [prop.NAME, prop.VIEWER_UID, prop.VALUE],
+            From=prop,
+            Where=prop.RESOURCE_ID == Parameter(&quot;resourceID&quot;)
+        )
</ins><span class="cx"> 
</span><span class="cx">         # Check that one property is present
</span><span class="cx">         home = yield self.homeUnderTest()
</span><span class="lines">@@ -859,9 +856,11 @@
</span><span class="cx">         resourceID = calobject._resourceID
</span><span class="cx"> 
</span><span class="cx">         prop = schema.RESOURCE_PROPERTY
</span><del>-        _allWithID = Select([prop.NAME, prop.VIEWER_UID, prop.VALUE],
-                        From=prop,
-                        Where=prop.RESOURCE_ID == Parameter(&quot;resourceID&quot;))
</del><ins>+        _allWithID = Select(
+            [prop.NAME, prop.VIEWER_UID, prop.VALUE],
+            From=prop,
+            Where=prop.RESOURCE_ID == Parameter(&quot;resourceID&quot;)
+        )
</ins><span class="cx"> 
</span><span class="cx">         # No properties on existing calendar object
</span><span class="cx">         rows = yield _allWithID.on(self.transactionUnderTest(), resourceID=resourceID)
</span><span class="lines">@@ -912,9 +911,11 @@
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         prop = schema.RESOURCE_PROPERTY
</span><del>-        _allWithID = Select([prop.NAME, prop.VIEWER_UID, prop.VALUE],
-                        From=prop,
-                        Where=prop.RESOURCE_ID == Parameter(&quot;resourceID&quot;))
</del><ins>+        _allWithID = Select(
+            [prop.NAME, prop.VIEWER_UID, prop.VALUE],
+            From=prop,
+            Where=prop.RESOURCE_ID == Parameter(&quot;resourceID&quot;)
+        )
</ins><span class="cx"> 
</span><span class="cx">         # One property exists calendar object
</span><span class="cx">         rows = yield _allWithID.on(self.transactionUnderTest(), resourceID=resourceID)
</span><span class="lines">@@ -1502,6 +1503,7 @@
</span><span class="cx">         # Re-add event with re-indexing
</span><span class="cx">         calendar = yield self.calendarUnderTest()
</span><span class="cx">         calendarObject = yield self.calendarObjectUnderTest(name=&quot;indexing.ics&quot;)
</span><ins>+        calendarObject.tr_change = True
</ins><span class="cx">         yield calendarObject.setComponent(component)
</span><span class="cx">         instances2 = yield calendarObject.instances()
</span><span class="cx">         self.assertNotEqual(
</span><span class="lines">@@ -1933,8 +1935,10 @@
</span><span class="cx">         rev = calendar._revisionsSchema
</span><span class="cx">         yield Delete(
</span><span class="cx">             From=rev,
</span><del>-            Where=(rev.HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;)).And(
-                   rev.COLLECTION_NAME == Parameter(&quot;collectionName&quot;))
</del><ins>+            Where=(
+                rev.HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;)).And(
+                rev.COLLECTION_NAME == Parameter(&quot;collectionName&quot;)
+            )
</ins><span class="cx">         ).on(self.transactionUnderTest(), homeID=home.id(), collectionName=&quot;calendar&quot;)
</span><span class="cx"> 
</span><span class="cx">         yield self.commit()
</span><span class="lines">@@ -2430,28 +2434,41 @@
</span><span class="cx"> &quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
</span><span class="cx"> 
</span><span class="cx">         calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</span><del>-        yield calendar.createCalendarObjectWithName(&quot;structured.ics&quot;,
-            Component.fromString(data))
-        cobj = yield self.calendarObjectUnderTest(name=&quot;structured.ics&quot;,
-            calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</del><ins>+        yield calendar.createCalendarObjectWithName(
+            &quot;structured.ics&quot;,
+            Component.fromString(data)
+        )
+        cobj = yield self.calendarObjectUnderTest(
+            name=&quot;structured.ics&quot;,
+            calendar_name=&quot;calendar&quot;,
+            home=&quot;user01&quot;
+        )
</ins><span class="cx">         comp = yield cobj.component()
</span><span class="cx">         components = list(comp.subcomponents())
</span><span class="cx"> 
</span><span class="cx">         # Check first component
</span><span class="cx">         locProp = components[0].getProperty(&quot;LOCATION&quot;)
</span><del>-        self.assertEquals(locProp.value(),
-            &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014&quot;)
</del><ins>+        self.assertEquals(
+            locProp.value(),
+            &quot;Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014&quot;
+        )
</ins><span class="cx">         structProp = components[0].getProperty(&quot;X-APPLE-STRUCTURED-LOCATION&quot;)
</span><del>-        self.assertEquals(structProp.value(),
-            &quot;geo:37.331741,-122.030333&quot;)
</del><ins>+        self.assertEquals(
+            structProp.value(),
+            &quot;geo:37.331741,-122.030333&quot;
+        )
</ins><span class="cx"> 
</span><span class="cx">         # Check second component
</span><span class="cx">         locProp = components[1].getProperty(&quot;LOCATION&quot;)
</span><del>-        self.assertEquals(locProp.value(),
-            &quot;Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;)
</del><ins>+        self.assertEquals(
+            locProp.value(),
+            &quot;Room with Address 2\n2 Infinite Loop, Cupertino, CA 95014&quot;
+        )
</ins><span class="cx">         structProp = components[1].getProperty(&quot;X-APPLE-STRUCTURED-LOCATION&quot;)
</span><del>-        self.assertEquals(structProp.value(),
-            &quot;geo:37.332633,-122.030502&quot;)
</del><ins>+        self.assertEquals(
+            structProp.value(),
+            &quot;geo:37.332633,-122.030502&quot;
+        )
</ins><span class="cx"> 
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="lines">@@ -2484,10 +2501,15 @@
</span><span class="cx">         self.patch(config.HostedStatus, &quot;Enabled&quot;, True)
</span><span class="cx"> 
</span><span class="cx">         calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</span><del>-        yield calendar.createCalendarObjectWithName(&quot;external.ics&quot;,
-            Component.fromString(data))
-        cobj = yield self.calendarObjectUnderTest(name=&quot;external.ics&quot;,
-            calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</del><ins>+        yield calendar.createCalendarObjectWithName(
+            &quot;external.ics&quot;,
+            Component.fromString(data)
+        )
+        cobj = yield self.calendarObjectUnderTest(
+            name=&quot;external.ics&quot;,
+            calendar_name=&quot;calendar&quot;,
+            home=&quot;user01&quot;
+        )
</ins><span class="cx">         comp = yield cobj.component()
</span><span class="cx">         components = list(comp.subcomponents())
</span><span class="cx"> 
</span><span class="lines">@@ -6976,3 +6998,571 @@
</span><span class="cx">         self.assertEqual(normalize_iCalStr(ical_future), normalize_iCalStr(data_future2) % relsubs, &quot;Failed future: %s&quot; % (title,))
</span><span class="cx">         self.assertEqual(normalize_iCalStr(ical_past), normalize_iCalStr(data_past2) % relsubs, &quot;Failed past: %s&quot; % (title,))
</span><span class="cx">         self.assertEqual(normalize_iCalStr(ical_inbox), normalize_iCalStr(data_inbox2) % relsubs, &quot;Failed inbox: %s&quot; % (title,))
</span><ins>+
+
+
+class TimeRangeUpdateOptimization(CommonCommonTests, unittest.TestCase):
+    &quot;&quot;&quot;
+    CalendarObject splitting tests
+    &quot;&quot;&quot;
+
+    EVENT1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event #2
+DTSTAMP:20100203T013909Z
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT3 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T130000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT4 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT5 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+STATUS:CANCELLED
+DTSTAMP:20100203T013909Z
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT6 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT1H
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT7 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+RRULE:FREQ=DAILY
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT8 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+RRULE:FREQ=DAILY;COUNT=10
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT9 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+RRULE:FREQ=DAILY
+EXDATE:{now}T120000Z
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    EVENT10 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+RRULE:FREQ=DAILY
+RDATE:{now}T150000Z
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+
+    @inlineCallbacks
+    def setUp(self):
+        yield super(TimeRangeUpdateOptimization, self).setUp()
+        yield self.buildStoreAndDirectory()
+        yield self.populate()
+
+        self.now = DateTime.getNowUTC()
+        self.now.setDateOnly(True)
+
+        self.trcount = 0
+        base_addInstances = CalendarObject._addInstances
+        def __addInstances(*args):
+            self.trcount += 1
+            return base_addInstances(*args)
+        self.patch(CalendarObject, &quot;_addInstances&quot;, __addInstances)
+
+        self.patch(config, &quot;FreeBusyIndexDelayedExpand&quot;, False)
+        self.patch(config, &quot;FreeBusyIndexSmartUpdate&quot;, True)
+
+
+    @inlineCallbacks
+    def populate(self):
+        yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
+        self.notifierFactory.reset()
+
+
+    @property
+    def requirements(self):
+        return {
+            &quot;home1&quot;: {
+                &quot;calendar_1&quot;: {},
+            },
+            &quot;user01&quot;: {
+                &quot;calendar&quot;: {},
+                &quot;inbox&quot;: {},
+            },
+            &quot;user02&quot;: {
+                &quot;calendar&quot;: {},
+                &quot;inbox&quot;: {},
+            },
+        }
+
+
+    @inlineCallbacks
+    def test_initalPUT(self):
+        &quot;&quot;&quot;
+        Test that initial PUT causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withoutTRChange(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT does not cause T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT2.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withoutOptimization(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        self.patch(config, &quot;FreeBusyIndexSmartUpdate&quot;, False)
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT does cause T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT2.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 2)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withTRChange(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT causes T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT3.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 2)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withTranspChange(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT causes T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT4.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 2)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withStatusChange(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT causes T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT5.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 2)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withTravelTimeChange(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT causes T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT6.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 2)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withRRULEChange(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT7.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT causes T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT8.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 2)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withEXDATEAdd(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT7.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT causes T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT9.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 2)
+
+
+    @inlineCallbacks
+    def test_updatePUT_withRDATEAdd(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest()
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.EVENT7.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 1)
+
+        # Second PUT causes T-R change
+        cobj = yield self.calendarObjectUnderTest()
+        yield cobj.setComponent(Component.fromString(self.EVENT10.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 2)
+
+
+    INVITE1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+ORGANIZER:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01@example.com
+ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    INVITE2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event
+DTSTAMP:20100203T013909Z
+ORGANIZER:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    INVITE3 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T120000Z
+DURATION:PT1H
+SUMMARY:New Event #2
+DTSTAMP:20100203T013909Z
+ORGANIZER:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    INVITE4 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100203T013849Z
+UID:uid1
+DTSTART:{now}T140000Z
+DURATION:PT1H
+SUMMARY:New Event #2
+DTSTAMP:20100203T013909Z
+ORGANIZER:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+    @inlineCallbacks
+    def test_schedulingPUT(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        # Need schedule-q off for this test
+        self.patch(config.Scheduling.Options.WorkQueues, &quot;Enabled&quot;, False)
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.INVITE1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 3)
+
+        # Attendee reply does not cause T-R change (except for inbox item and attendee resource transp change)
+        cal = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;calendar&quot;)
+        cobjs = yield cal.calendarObjects()
+        self.assertEqual(len(cobjs), 1)
+        yield cobjs[0].setComponent(Component.fromString(self.INVITE2.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 5)
+
+        # Organizer summary change does not cause T-R change (except for inbox item)
+        cobj = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;)
+        yield cobj.setComponent(Component.fromString(self.INVITE3.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 6)
+
+        # Organizer dtstart change causes T-R change
+        cobj = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;)
+        yield cobj.setComponent(Component.fromString(self.INVITE4.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 9)
+
+
+    @inlineCallbacks
+    def test_schedulingPUT_withoutOptimization(self):
+        &quot;&quot;&quot;
+        Test that second PUT withe time change causes a TIME_RANGE update
+        &quot;&quot;&quot;
+
+        self.patch(config, &quot;FreeBusyIndexSmartUpdate&quot;, False)
+
+        # Need schedule-q off for this test
+        self.patch(config.Scheduling.Options.WorkQueues, &quot;Enabled&quot;, False)
+
+        # First PUT causes T-R change
+        cal = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield cal.createObjectResourceWithName(&quot;1.ics&quot;, Component.fromString(self.INVITE1.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 3)
+
+        # Attendee reply does cause T-R change (except for organizer update)
+        cal = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;calendar&quot;)
+        cobjs = yield cal.calendarObjects()
+        self.assertEqual(len(cobjs), 1)
+        yield cobjs[0].setComponent(Component.fromString(self.INVITE2.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 5)
+
+        # Organizer summary change causes T-R change
+        cobj = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;)
+        yield cobj.setComponent(Component.fromString(self.INVITE3.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 8)
+
+        # Organizer dtstart change causes T-R change
+        cobj = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;)
+        yield cobj.setComponent(Component.fromString(self.INVITE4.format(now=self.now.getText())))
+        yield self.commit()
+
+        self.assertEqual(self.trcount, 11)
</ins></span></pre>
</div>
</div>

</body>
</html>